-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
What I'd like to be able to do is give some portion of my app the ability to define states/routes at runtime:
$stateService.add('somewhere.runtimeState', {
url: '/runtime-state',
controllerProvider: myControllerProvider,
templateProvider: myTemplateProvider
});
I know there's already been some discussion with regards to lazy loading. Unfortunately they've suggested some fairly ugly APIs and introduce what I feel is an unnecessary level of complexity to something that should be as simple as gaining access to the $stateProvider
API at runtime. Ideally this is not the kind of thing I need another angular module dependency for.
In the name of keeping all the concerns nicely separated, I feel like this approach would allow one to pre-load routes (thereby gaining the ability to generate URIs to them) as well as optionally perform any visuals/processing while the controller and/or template is being resolved. Unless I'm mistaken, it gives me enough control to integrate whatever mechanisms I see fit to produce the results ui router needs. Any other parameters or schema involved with exposing runtime definition of states risks becoming too implementation specific.
On the off chance that there already is runtime access to this API, I apologize and definitely was not lead to believe such by the documentation. I'd love to be directed to it and maybe I could then suggest here how it could be improved.