我正在尝试导航到嵌套的辅助路线,但我不断收到错误消息:
ERROR Error: Uncaught (in promise):
Error: Cannot match any routes. URL Segment: 'sign-in'
我试图导航到的 URL:
http://localhost:4200/(modalcontainer:modals//modalview:sign-in)
我的路由配置如下所示:
{
path: 'modals',
component: ModalsComponent,
outlet: 'modalcontainer',
children: [
{
path: 'register',
outlet: 'modalview',
component: ModalRegisterComponent
},
{
path: 'sign-in',
outlet: 'modalview',
component: ModalSigninComponent
}
]
}
所以有 2 个router-outlets
是modalcontainer
和modalview
。后者在ModalsComponent
.
应用组件
<router-outlet></router-outlet>
<router-outlet name="modalcontainer"></router-outlet>
模态组件
<div class="overlay" (click)="close($event)">
<router-outlet name="modalview"></router-outlet>
</div>
填充正常,modalcontainer
但是一旦我尝试填充modalview
插座,它就会出错。
我尝试过的导航方式是:
[routerLink]="[{outlets: {'modalcontainer': ['modals'], 'modalview': ['register']}}]"
[routerLink]="[{outlets: {'modalcontainer': ['modals'], 'modalview': ['modals', 'register']}}]"
[routerLink]="['modals', {outlets: {'modalview': ['register']}}]"
- 直接在地址栏输入
http://localhost:4200/(modals:modals//modal:sign-in)
this.router.navigate([{outlets: {'modalcontainer': ['modals'], 'modalview': ['register']}}]);
this.router.navigateByUrl('/(modals:modals//modal:sign-in)');
是我的配置中的某些东西还是我访问 URL 的方式?或者这是一个错误?