Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs Angular 4.X:初始化子组件路由器_Angularjs_Angular Ui Router - Fatal编程技术网

Angularjs Angular 4.X:初始化子组件路由器

Angularjs Angular 4.X:初始化子组件路由器,angularjs,angular-ui-router,Angularjs,Angular Ui Router,我有以下应用程序路由配置: const routes: Routes = [ {loadChildren: './modules/faq/faq.module', path: 'faq'}, {loadChildren: './modules/pagination/pagination.module', path: 'page'}, {loadChildren: './modules/appointmentAgreement/appointmentAgreement.mo

我有以下应用程序路由配置:

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},
    ]
}];
现在,如果page/terminvereinbarung打开,我希望应用程序重定向到/terminvereinbarung/thema

我怎样才能做到这一点


非常感谢adcance。

请尝试在任命协议组件中执行以下操作:

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},
]

}])

保持所有路由不变,只需尝试在子模块的子模块中添加此重定向

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},
 ]
}];

非常感谢您的快速回答。您的代码段中似乎存在语法问题。你能给出正确的答案吗?我已经更新了我的答案,并删除了路径周围的花括号。我尝试了你更新的解决方案,但不幸的是它不起作用。调用/terminvereinbarung不会呈现任何组件调用/terminvereinbarung/thema会给出错误:错误:无法匹配任何路由。URL段:“terminvereinbarung/TheMaals不工作,我无法选择任何其他子视图,然后始终加载TopicSectionComponent。我已对我的答案进行了更改,请检查。