• Resolved flight1307

    (@flight1307)


    Does anyone see any problems with this going forward? I have got Angular JS running on my child theme using a simple script tag:

    <script src="<?php echo get_stylesheet_directory_uri();?>/js/angularjs/angular.min.js"></script>

    WordPress register script and enqueue script and add action methods have not worked but the above simple script tag on the page on which I’m deploying Angular DOES work. Does anyone see any problems with this going forward?

    Many thanks

    InFlight

Viewing 1 replies (of 1 total)
  • You really should be enqueuing the script, not doing it that way.

    IF you were to write a script tag like that, you should use
    get_bloginfo('template_directory');

    But here is how my ANgularJS app works (enqueue):

    function DashScripts(){
    //ANGULAR CORE
    wp_enqueue_script('angular-core', '//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.js', array('jquery'), null, false);
    wp_enqueue_script('angular-route', '//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-route.min.js', array('angular-core'), null, false);
    wp_enqueue_script('angular-resource', '//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-resource.min.js', array('angular-route'), null, false);
    
    //MY ANGULAR APP
    wp_enqueue_script('angular-app', get_bloginfo('template_directory').'/js/angular-app.js', array('angular-resource'), null, false);
    //wp_enqueue_script('angular-directives', get_bloginfo('template_directory').'/js/angular-directives.js', array('angular-app'), null, false);
    wp_enqueue_script('angular-routes', get_bloginfo('template_directory').'/js/angular-routes.js', array('angular-app'), null, false);
    wp_enqueue_script('angular-factories', get_bloginfo('template_directory').'/js/angular-factories.js', array('angular-app'), null, false);
    
    //ANGULAR CONTROLLERS
    wp_enqueue_script( 'angular-home', get_bloginfo('template_directory').'/js/angular-homeCtrl.js', array('angular-factories'), null, false);
    wp_enqueue_script( 'angular-dash', get_bloginfo('template_directory').'/js/angular-dashCtrl.js', array('angular-factories'), null, false);
    wp_enqueue_script( 'angular-teacher', get_bloginfo('template_directory').'/js/angular-teacherCtrl.js', array('angular-factories'), null, false);
    wp_enqueue_script( 'angular-student', get_bloginfo('template_directory').'/js/angular-studentCtrl.js', array('angular-factories'), null, false);
    ... More AngularJS related scripts and styling follows
    }

Viewing 1 replies (of 1 total)

The topic ‘simple way to run Angular JS’ is closed to new replies.