Why would I want to load AngularJS files in any order with AngularJS Loader? -


this question has been asked before , see answers suggest @ angular seed this:

// include angular loader, allows files load in order /*  angularjs v1.0.0rc1  (c) 2010-2012 angularjs http://angularjs.org  license: mit */ 'use strict';(function .............................................. $script([   'lib/angular/angular.js',   'js/app.js',   'js/services.js' ], function() {   // when done, execute bootstrap angular application   angular.bootstrap(document, ['myapp']); }); 

but still don't understand advantage there loader. can explain me difference between above , following code:

<script src='lib/angular/angular.js'></script> <script src='js/app.js'></script> <script src='js/services.js'></script> <script type="text/javascript">     angular.element(document).ready(function () {         angular.bootstrap(document, ['mainapp']);     }); 

in simple example, might not matter. when have many modules dependent on each other however, end managment nightmare. example loading moduleb.js before modulea.js (if moduleb relies on modulea) cause error. angular loader load modulea.js first, if defined after moduleb.js in array.

another benefit loads files asynchronously (which useful if have different areas of application different library requirements: async load allows the home page render , start running before libraries become available).


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -