Routes should allow to load modules/controllers on demand
When you route to a specific location, the template for that route is loaded on demand. There should also be a feature to specify a module or controller script that will be loaded when the user routes to the given location.
There is a solution using require.js (https://github.com/matys84pl/angularjs-requirejs-lazy-controllers), but it adds another library and another nesting level (angular module definitions within require.js module definitions)
As for the use case:
- Increase the initial startup time by loading scripts only when they are needed.
- Only serve scripts to users that have the right to see the route they are used in.
- Enhanced modularity.
it's 2016. something should have been done..
:)
May the awesomeness will always be with you,
Tri Rahmat Gunadi - JUJI http://jujiyangasli.com Ph 0813.1012.8924
On Mon, Oct 3, 2016 at 7:02 PM, pyotruk [email protected] wrote:
+1
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/angular.js/issues/2135#issuecomment-251088850, or mute the thread https://github.com/notifications/unsubscribe-auth/AAeH8RayUZA4MUmqWPnUIyb5S6Rsg5PRks5qwO64gaJpZM4AfSRI .
The de-facto solution appears to be to use a 3rd party https://oclazyload.readme.io which appears to solve the problem in a generic way.
In 1.6.7, it will be possible to load new modules into the injector after the app has been initialized, e.g. in a route's resolve function. You'll still have to provide a way to load and execute the script though. See https://github.com/angular/angular.js/commit/34237f929927295392bbb1a600e78cbde581839a for more info