伟大的孙子路线不会激活

时间:2017-12-06 10:32:38

标签: angular router

我正在尝试通过网址" / 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将被触发,网址将被更改为" / Recruitment / Application / 2 / ApplicantDetails" ,但该组件不会是ApplicantDetailsS​​tageComponent,而是将加载404页面。

" RecruitmentComponent"正在加载正常(如果我删除redirectTo),我可以提取&#34 ;:apprentsId"在里面。

有人看到任何明显的东西吗?

1 个答案:

答案 0 :(得分:0)

问题在于“pathMatch:'full',”我将它从子路径中移除,一切都开始起作用了。