codebot
codebot

Reputation: 707

Default path in a path with children

I am using angular 6 and for the cms of the app I have the following paths set up in the app.modules.ts file.

{ path: 'cms', component: CmsComponentComponent, children: [
  { path: 'register', component: RegisterComponent },
  { path: 'login', component: LoginComponent },
  { path: 'profile', component: ProfileComponent, canActivate:[AuthGuard] },
  { path: 'educate', component: EducateComponent, canActivate:[AuthGuard] }
]},

I would like to have a default cms, so if I type app/cms I would got to Register.

How can I do this?

Thanks

Upvotes: 0

Views: 46

Answers (1)

Johan Rin
Johan Rin

Reputation: 1950

From my understanding, you only have to add a redirect route like this:

{ path: 'cms', component: CmsComponentComponent, children: [
  { path: 'register', component: RegisterComponent },
    ...
  { path: '', redirectTo: '/register', pathMatch: 'full' }
]},

Upvotes: 1

Related Questions