我在 Angular2 2.1.2 上使用命名路由器 socket 时遇到问题。
我收到错误:
Cannot find the outlet XOutlet to load 'YComponent'
错误本身很明显,但我卡住了,找不到解决方法。
HTML 看起来像这样:
<router-outlet name="XOutlet"></router-outlet>
<!-- Main content -->
<div class="content-wrapper">
<router-outlet></router-outlet>
</div>
路由文件:
{
path: 'other',
component: OtherComponent,
children: [
{
path: 'list',
component: YComponent,
outlet: 'XOutlet'
}
]
},
链接
<a [routerLink]="['other', {outlets: {'XOutlet': 'list'}}]"><span>Other</span></a>
我错过了什么?
谢谢
编辑:根据 Oleg Barinov 的评论,提供的 HTML 是基本 HTML 的一部分,而不是来自 OtherComponent HTML。
最佳答案
使用 <a [routerLink]="['/', {outlets: {'XOutlet': 'list'}}]"><span>Other</span></a>
对于这种实现。
关于Angular2 路由器 : Cannot find the outlet XOutlet to load YComponent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40343588/