What is angular-loader.js for?

Angularjs

Angularjs Problem Overview


I saw a similar question on the Google groups and also here on Stackoverflow. Both times the question was not answered. The code in this file doesn't make it very clear about what exactly it does and how it is used. Also it's not clear from the Angular documentation.

Can someone explain how this is used. Also can this be used along with Require.js?

Angularjs Solutions


Solution 1 - Angularjs

Angular loader allows your angular scripts to be loaded in any order.

As angular-seed project shows us, Angular loader does not have any specific api, you just put it at the top of your index file (so that it's executed first) and then proceed to load your application files anyway you prefer.

But, the most important thing for your use case is that you don't really need angular loader at all. RequireJS also allows your files to be loaded in any order, but it also provides you with many other features that angular loader just isn't made for.

So, yes, you may use it with RequireJS, but you don't need to, because it becomes redundant.

Solution 2 - Angularjs

>Angular modules solve the problem of removing global state from the application and provide a way of configuring the injector. As opposed to AMD or require.js modules, 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.

http://docs.angularjs.org/tutorial/step_07#anoteaboutdiinjectorandproviders

Solution 3 - Angularjs

It allows for you asynchronously load files when bootstrapping your angular application. A good example is the angular-seed project that has an index-async.html file that does this.

index-async.html

This is useful for using other libraries that load in modules asynchronously.

Solution 4 - Angularjs

See angular-async-loader: https://github.com/subchen/angular-async-loader/

To async load following components:

  • List item
  • controller
  • services
  • filter
  • directive
  • value
  • constant
  • provider
  • decorator

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlan2View Question on Stackoverflow
Solution 1 - AngularjsStewieView Answer on Stackoverflow
Solution 2 - AngularjsDaidaiView Answer on Stackoverflow
Solution 3 - AngularjsXesuedView Answer on Stackoverflow
Solution 4 - AngularjsSubView Answer on Stackoverflow