I am working with AngularJS from a short amount of time so I am still a kind of lost with it. Sorry if the question is trivial or was already asked... I have seen so many different questions / posts / docs that I am really confused.
This is the problem I am facing: I would like to dynamically add dependencies to my app (I am going to refer to it as rootApp), before bootstrap it.
At the moment the bootstrap happens manually: for what I have read on the web, should be possible to dynamically add dependencies to the app before bootstrap it (and that is why the bootstrap is happening manually).
I have different templates (powered by Template Toolkit) that can load different modules as dependency: for example, the template "myComponent" needs to load, as dependency, the Angular module myComponent; the template "myTable" needs to load, as dependency, the Angular module NGTable, etc...
What I would like to do is to define the module for the rootApp as:
// NOTE: no dependencies as argument!
rootAppModule = angular.module('rootApp', []);
and then add dependencies on demand, something like:
rootAppModule.pushDependency( myComponentModule );
rootAppModule.pushDependency( NGTableModule );
then finally bootstrap:
angular.bootstrap(document, ['rootAppModule']);
Someone can help me?
PS I have seen there are Angular plugins to load dependencies AFTER the bootstrap of the app but here I would be happy doing it before the bootstrap. It should be easier, so I would prefer to avoid (not needed?) complexity.
edit:
I have found the array "requires", follows an example:
angular.module("rootAppModule").requires.push("myComponentModule");
from here
Anybody can tell if that is a reliable solution?