我有以下应用程序路由配置:
const routes: Routes = [
{loadChildren: './modules/faq/faq.module', path: 'faq'},
{loadChildren: './modules/pagination/pagination.module', path: 'page'},
{loadChildren: './modules/appointmentAgreement/appointmentAgreement.module#AppointmentAgreementModule', path: 'terminvereinbarung'}
];
并且约会协议子模块路由配置
const appointmentAgreementRoutes: Routes = [{
path: '',
children: [
{path: 'thema', component: TopicSectionComponent},
{path: 'filiale', component: BranchSectionComponent},
{path: 'termin', component: DatetimeSectionComponent},
{path: 'daten', component: PersonalDataSectionComponent},
{path: 'bestaetigung', component: ConfirmationSectionComponent},
]
}];
现在我希望应用程序重定向到/ terminvereinbarung / thema如果page / terminvereinbarung是开放的。
我怎样才能实现这个目标?
非常感谢adcance。
答案 0 :(得分:1)
尝试在appointmentAgreement组件中执行以下操作:
const appointmentAgreementRoutes: Routes = [{
{
path: 'terminvereinbarung',
redirectTo: 'thema',
pathMatch: 'full'
},
{
path: 'terminvereinbarung',
component: TopicSectionComponent,
}
children: [
{path: 'thema', component: TopicSectionComponent},
{path: 'filiale', component: BranchSectionComponent},
{path: 'termin', component: DatetimeSectionComponent},
{path: 'daten', component: PersonalDataSectionComponent},
{path: 'bestaetigung', component: ConfirmationSectionComponent},
]
}];
答案 1 :(得分:1)
保留所有路由,因为它只是尝试在子模块
中的子项中添加此重定向const appointmentAgreementRoutes: Routes = [{
path: '',
children: [
{ path: '', redirectTo: 'thema', pathMatch: 'full' },
{path: 'thema', component: TopicSectionComponent},
{path: 'filiale', component: BranchSectionComponent},
{path: 'termin', component: DatetimeSectionComponent},
{path: 'daten', component: PersonalDataSectionComponent},
{path: 'bestaetigung', component: ConfirmationSectionComponent},
]
}];