I'm architecting a project where we have one module acting as our shell, handling global styles, navigation, etc, with an ng:view
getting filled by directives provided by our second module with all the pages.
I would really like to find a way for the shell to inspect the pages module, discovering the nav structure dynamically, rather than defining it by hand or having every page inject itself both in the pages
module AND to the shell
module. On its own, the injector doesn't seem to like doing that.
EDIT
As clarification: while I have a fabulous workaround with a pagesProvider service, I am still looking for an answer as to whether Angular 1.2.x has a mechanism to introspect modules.
Firstly: at the end all
injected
objects (like services, filters, controllers) will end up in one big bag (something like global namespace). So it is enough to inject eachpage
intopages
andpages
intoshell
. (mind the possibility of name-conflicts.)Secondly: at this time, there is no support for lazy loading of modules. So you should know all your modules beforehand, so there is actually no need to check which objects are present and which not, as either there are all of them or the application has not started at all.
I do not know what you actually mean by discovering
nav structure
and how it will be defined. But, what you can do is:constant
in which thenav structure
of this page will be stored.constant
fromshell
when needed. If you need to know dynamically theid
of active page, just set this information somewhere -- probably asvalue
-- when the pages gets activated.Some alternatives:
hash-map
frompage-id
s topage-nav-structure
s.