Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: State 'quizzes' is already defined #944

Closed
stnor opened this issue Aug 25, 2021 · 2 comments
Closed

Error: State 'quizzes' is already defined #944

stnor opened this issue Aug 25, 2021 · 2 comments

Comments

@stnor
Copy link
Contributor

stnor commented Aug 25, 2021

Hi,
I am merging six different angular apps to one app, and have a 'root' parent and all the old apps at lazy child states under that.

Like this:

const rootState = {
    name: 'root',
    url: '',
    component: AppComponent,
    redirectTo: 'start'
};

const nompFutureState = {
    parent: 'root',
    name: 'nomp.**',
    url: '/nomp',
    loadChildren: () => import('./nomp/nomp-app.module').then(mod => mod.NompAppModule)
};

const nompPlusFutureState = {
    parent: 'root',
    name: 'plus-app.**',
    url: '/nomp-plus',
    loadChildren: () => import('./nomp-plus/nomp-plus.module').then(mod => mod.NompPlusModule)
};

The "Nomp" state declaration:

const appState: Ng2StateDeclaration = {
    parent: 'root',
    name: 'nomp',
    component: NompAppComponent,
    url: '/nomp'
}

The "NompPlus" state declaration:

const plusAppState: Ng2StateDeclaration = {
    parent: 'root',
    name: 'plus-app',
    component: NompPlusComponent
}

In the nompFutureState there is a 'quizzes' non-lazy state.

const levelsState: Ng2StateDeclaration = {
    parent: "nomp",
    name: "quizzes",
    params: {
        "levelid": {
            type: "int",
            value: null,
            squash: true
        }
    },
    redirectTo: transition => {
        let ts: TranslateService = transition.injector().get(TranslateService);
        let lang = ts.currentLang;
        return {state: "quizzes-" + lang, params: transition.params()};
    }
}

When adding this state I'm getting "Error: State 'quizzes' is already defined".

export const quizzesState: Ng2StateDeclaration = {
    parent: 'plus-app',
    name: "quizzes",
    url: "/quizzes",
    component: QuizzesComponent
};

Here's the trace;
Screenshot 2021-08-25 at 14 49 39

What's going wrong here? It's a blocker for me, so any hints are greatly appreciated. @christopherthielen

@stnor
Copy link
Contributor Author

stnor commented Aug 25, 2021

Versions

    "@angular/core": "10.2.4",
    "@uirouter/angular": "8.0.1",
    "@uirouter/core": "6.0.8",
    "@uirouter/rx": "0.6.5",

@stnor
Copy link
Contributor Author

stnor commented Aug 26, 2021

Nevermind, I ran the Visualizer, which made it obviously clear that I was too tired when hurrying through this.

@stnor stnor closed this as completed Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant