这是我的子路线的配置:
export const ProjectRouter: RouterConfig = [
{ path: 'projects', component: MainProjectComponent,
children: [
{ path: 'new', component: NewProjectComponent, canActivate: [AuthRouter] },
{ path: ':id', component: ProjectComponent, canActivate: [AuthRouter] },
{ path: '', component: ProjectsComponent, canActivate: [AuthRouter] }
] }
];
MainProjectComponent:
@Component({
moduleId: module.id,
template: '<router-outlet></router-outlet>',
directives: [ROUTER_DIRECTIVES]
})
export class MainProjectComponent {}
到“/ project / new”或“/ projects /:id”的路由正在运行,但是当我转到“/ projects”时它没有显示ProjectsComponent(它基本上是一个列表)。
没有错误,只是一个空的路由器插座。 我不是我在这里失踪的......
答案 0 :(得分:0)
尝试将pathMatch: 'full'
添加到空路径路径:
{ path: '', component: ProjectsComponent, canActivate: [AuthRouter] , pathMatch: 'full'}
答案 1 :(得分:0)
这是版本alpha.3的错误。更新到beta.2后,一切正常。