【问题标题】:Great grandchild route won't activate曾孙路线不会激活
【发布时间】: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" ,但组件不会是 ApplyDetailsS​​tageComponent 和将加载 404 页面。

“RecruitmentComponent”加载正常(如果我删除了redirectTo),我可以在其中提取“:applicantId”。

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

【问题讨论】:

    标签: angular router


    【解决方案1】:

    问题出在“pathMatch: 'full'”中,我从子路由中删除了它,一切都开始工作了。

    【讨论】:

      猜你喜欢
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-10
      • 2016-12-21
      • 1970-01-01
      相关资源
      最近更新 更多