Angular 2 路由器:未显示子项

Angular 2 router : children not siplayed

我正在尝试在 angular 2 中为我的项目实施用户身份验证包:http://jasonwatmore.com/post/2016/09/29/angular-2-user-registration-and-login-example-tutorial

我将整个文件夹放入一个名为 "loginMGR" 的超级文件夹中,在模块、组件和文件名中将 "app" 重命名为 "loginMGR" 并更改了 app-routing.module (现在将 loginMGR.module) 命名为:

imports...

const loginRoutes: Routes = [
  {
    path: '',
    component: HomeComponent,
    canActivate: [AuthGuard],
    children: [
      { path: 'identification', component: LoginComponent },
      { path: 'enregistrement', component: RegisterComponent },
    ]
  },

  // otherwise redirect to home
  { path: '**', redirectTo: '' }
];

@NgModule({
  imports: [
    RouterModule.forChild(loginRoutes)
  ],
  exports: [
    RouterModule
  ]
})

export class LoginRoutingModule

我的应用程序路由模块通过以下路由命名为 link:

const routes: Routes = [
...
        { path: 'authentification', component: LoginMGRComponent },
... 

多亏了这个按钮,我才能访问捆绑包:

<a [routerLink]="['/authentification']" [routerLinkActive]="['router-link-active']" [routerLinkActiveOptions]="{exact:true}" class="navbar-link">

但是,我的 loginMGR.component.html 的路由器插座和警报保持为空,并且不会 link 他们应该访问的不同组件(在这种情况下,'' 将是"home").

知道我做错了什么吗?

谢谢

由于您在 LoginRoutingModule 中定义了您的子路由,只需将其导入您的应用模块,然后在应用模块 Routes 中删除该路由。