带子路径的默认路径

时间:2019-01-19 23:35:50

标签: angular angular6 angular-routing

我使用的是角度6,对于应用程序的cms,我在app.modules.ts文件中设置了以下路径。

{ 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] }
]},

我想要一个默认的cms,所以如果我输入app/cms,我就必须注册。

我该怎么做?

谢谢

1 个答案:

答案 0 :(得分:1)

据我了解,您只需要添加这样的重定向路由:

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