Hello everyone I've been trying to do this with no luck for a few days.
is there anyway to load asynchronously some js scripts(which contain angular modules) and inject them to the running app after it has been initialized.
Basically I have a container DOM element that will be populated with some HTML requested from the server, based on this HTML code I will decide which js files (modules) will be required, then load them asynchronously inject the modules to the angular app and compile the content with the new injected modules.
I tried but every time I do the bootstrap method injecting the module the Main Controller fires up and erases all my scope state. :(
Any help around here?
It's ugly, but it works: http://jsfiddle.net/MzseV/7/
It basically works by iterating the module's _invokeQueue
member and applying functions within using the providers used for registering services, controllers and directives (NOTE: these need to be captured before bootstrapping AFAIK). This will probably also re-register anything you've previously registered so you might want some heuristic to only pick the ones you want, although I'm not sure if there's any damage in re-registring.
Again, it's fairly hideous and hacky so I'd only use as a last resort.
Here's the question I asked and later answered about this.
EDIT: just noticed how old this question is, hope it still helps someone.