Wednesday, December 18, 2013

getting rid of script tags in AngularJS

About seven and a half minutes into this movie comes the suggestion that this:

<html lang="en" ng-app="myHelloWorldApplication">

 
 

...needs to be swapped out (downstream of a require.js script tag) with something like so:

$script([
   'lib/angular/angular.js',
   'js/app.js',
   'js/services.js',
   'js/controllers.js',
   'js/filters.js',
   'js/directives.js'
], function() {
   angular.bootstrap(document, ['myHelloWorldApplication']);
});

 
 

...in the name of cleaning up an AngularJS implementation which uses script tags to one that has an AMD pattern. This reiterates what is given here as well: "Angular modules don't try to solve the problem of script load ordering or lazy script fetching. These goals are orthogonal and both module systems can live side by side and fulfil their goals" ...I need to actually attempt the script-tag-to-AMD migration. Let's see how it goes.

No comments:

Post a Comment