我使用輔助插座導航時遇到問題。使用輔助插座導航時發生角度4錯誤
- 我有一個LayoutComponent被加載到主路由器插座。
- 的LayoutComponent包含一個名爲次要出口
content-outlet
到目前爲止,一切都很好,我能夠導航到例如/accounts/1/overview
,並且content-outlet
加載正確的組件(OverviewComponent)。但是,當我點擊側邊欄的鏈接導航到/accounts/1/stats
路線我得到一個錯誤:
Error: Cannot activate an already activated outlet
同樣的事情發生,如果我第一次瀏覽到/accounts/1/stats
,然後嘗試激活/accounts/1/overview
。
的LayoutComponent:
<app-sidebar></app-sidebar>
<div class="topbar-content-wrapper">
<app-topbar></app-topbar>
<div class="content-wrapper">
<router-outlet name="content-outlet"></router-outlet>
</div>
</div>
側欄導航:
<a href="#" [routerLink]="[ '/accounts', accountId, 'overview' ]">Overview</a>
<a href="#" [routerLink]="[ '/accounts', accountId, 'stats' ]">Stats</a>
路線:
{
path: 'accounts/:accountid',
component: LayoutComponent,
canActivate: [AuthService],
children: [
{
path: 'stats',
children: [
{
path: '',
component: StatsComponent,
outlet: 'content-outlet'
}
]
},
{
path: 'overview',
children: [
{
path: '',
component: OverviewComponent,
outlet: 'content-outlet'
}
]
}
]
爲什麼你有HREF =在導航欄鏈接「#」? –
我不覺得這很重要嗎? @ Jota.Toledo – Andain