Skip to content

Add a facility to allow states to be defined at runtime. #1274

@atrauzzi

Description

@atrauzzi

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions