2

Currently the only way that I know of to make module dependencies available is to specify them when a module is declared. e.g.:

angular.module("myApp",["myDependentModule"]);

This becomes a problem when the app gets large and modules have a lot of dependencies, libraries that must be loaded. If these libraries aren't required for any of the modules that the first page the user visits, it seems that those dependencies could be deferred to improve load time.

Any advice would be appreciated.

Vincil Bishop
  • 1,594
  • 17
  • 21

2 Answers2

2

Use angular.injector(...) https://docs.angularjs.org/api/ng/function/angular.injector

Mention and example is here:

 var injector = angular.injector(['someModule']);
 var someService = injector.get('someService');

AngularJS - Injecting factory from another module into a provider

Community
  • 1
  • 1
Artem K.
  • 804
  • 6
  • 15
1

you can use lazy load moduls. https://oclazyload.readme.io/docs

avim101
  • 300
  • 1
  • 2
  • 9
  • I've used this library, but have not been successful in getting it to load modules. What I am really trying to do it make dependent modules available in UI router. Maybe I need to adjust my pattern because it seems like I am running up against a limitation where it can't know about the routes specified in other modules until those modules are loaded, so it can't lazy load them. – Vincil Bishop Jun 17 '16 at 01:32