Boot module after Angular boot module

I am trying to download and deploy the module after the initial loading of the application. For example, let my original module:

angular.module('mainApp', []); 

Later I understand that the user needs all the routes available through secondaryApp to open them. So now I need my module to look something like this:

 angular.module('mainApp', ['secondaryApp']); 

I have successfully lazyLoading the secondApp js file, but I cannot add it to mainApp. I tried adding it to the required array, i.e.

 var app = angular.module('mainApp'); app.requires[app.requires.length] = 'secondaryApp'; 

This adds the module name to the require array, but mainApp still does not have access to the routes / states provided in secondaryApp .

Does anyone have any suggestions? I was stuck on this for a while.

Thanks!

+5
source share
1 answer

To be clear, you cannot define angular.module('mainApp', []); more than once.

Each time you declare a module with dependencies per se, it cancels the previous declaration.

0
source

Source: https://habr.com/ru/post/1210941/


All Articles