【发布时间】:2017-12-06 22:33:54
【问题描述】:
我正在尝试通过 url“/Recruitment/Application/2/ApplicantDetails”激活组件。我正在使用 angular@5.0.0
路线:
父路由
{
path: 'Recruitment', loadChildren: 'ngModules/dashboard/RecruitmentDashboardModule#RecruitmentDashboardModule',
canActivate: [AuthGuard]
},
{
path: '**', component: NotFoundComponent,
}
}
孩子
RouterModule.forChild([
{ path: 'Application/:applicantId', loadChildren: '/ngModules/recruitment/RecruitmentModule#RecruitmentModule', pathMatch: 'full' }
])
孙子和曾孙
{
path: '', component: RecruitmentComponent,
children: [
{ path: 'ApplicantDetails', component: ApplicantDetailsStageComponent },
{
path: '',
redirectTo: 'ApplicantDetails',
pathMatch: 'full',
},
]
}
如果我将 "/Recruitment/Application/2" 传递到浏览器中,最后一个 redirectTo 将被触发,并且 url 将更改为 "/Recruitment/Application/2/ApplicantDetails" ,但组件不会是 ApplyDetailsStageComponent 和将加载 404 页面。
“RecruitmentComponent”加载正常(如果我删除了redirectTo),我可以在其中提取“:applicantId”。
有没有人看到任何明显的东西?
【问题讨论】: