Skip to content

How to avoid big state config function in large applications #54

Closed
@ffesseler

Description

@ffesseler

I'm writing a large app, up to 4 level deep navigation with URL routing.
I've declared all states in the main app module. That means I've something like :

angular.module('myApp').config(function ($stateProvider) {
$stateProvider
.state("toplevelfeature", { url : '/topleavelFeature'...})
.state("toplevelfeature2", { url : '/topleavelFeature2'...})
.state("toplevelfeature.midfeature", { url : '/midFeature'...})
.state("toplevelfeature.midfeature2", { url: '/midFeature2...})
.state("toplevelfeature.midfeature.anothernestedfeature", { url: '/anothernestedfeature...})
});

I've already defined a dozen of states and I know I will have to handle at least 50 other ones. Obviously, I'd like to split state definitions to avoid a giant config method!
For now, each feature get its own module so I thought I would be able to do something like this :

angular.module('anothernestedfeature').config(function ($stateProvider) {
$stateProvider
.state("toplevelfeature.midfeature.anothernestedfeature.home", {...})
.state("toplevelfeature.midfeature.anothernestedfeature.detail", {...})
.state("toplevelfeature.midfeature.anothernestedfeature.other", {...})
});

Unfortunately, when I do that, there is an error saying parent state (here: toplevelfeature.midfeature) can't be found.

Any idea about this? (Sorry If I'm not on the right place to ask this but I didn't find any information about where to ask these kind of questions)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions