I am trying to inject angular module dynamically after some event as -
app.requires.push('projects');
console.log(app.requires);
I am referring to this link How to inject modules to main Angular app module on the fly to inject the module on occurrence of an event.
I have created a plunkr for the complete poc I have created. So on app.requires call it actually pushes projects module as dependency however when I click on link navigating to states defined inside the projects module, it logs an error stating Could not resolve 'projects.login' from state ''. Although these links work if I inject to module at the start only like guides module.
PS: Loading of project module happens upon clicking of button in index route.
app.requires.push('projects')will take effect if the app will be re-bootstrapped You can't add new modules to already bootstrapped app, Angular needs to be thoroughly patched to make this possible (something that ocLazyload does). It isn't clear whyloadScript2in your example should be loaded dynamically, there is a good chance that you have XY problem.