0
對我的應用程序組件兩個環節我如何routerLinkActive非錨鏈接
<a routerLink="/dashboard" routerLinkActive="active">Dashboard</a> --> app/dashboard
<a routerLink="/heroes" routerLinkActive="active">Heroes</a> --> app/heroes
我點擊英雄我進入「英雄的詳情」頁面,但「英雄」後鏈接是不活躍。
我想強調的 「英雄」 錨時我真的對應用程序/細節/:ID
path: 'detail/:id'
這就是我的全部路線常量:
const appRoutes: Routes = [
{
path: '',
redirectTo: '/dashboard',
pathMatch: 'full'
},
{
path: 'detail/:id',
component: HeroDetailComponent
},
{
path: 'dashboard',
component: DashboardComponent
},
{
path: 'heroes',
component: HeroesComponent
}
];
的善意幫助讚賞
唯一的事情就是讓'細節/:id'路線'heroes'路線的子路徑。我不認爲有一種方法可以告訴角度,即使您不在該路線上,也可以顯示路線處於活動狀態。 –
類似於:'{path:'heroes',children:[{path:「」,component:HeroesComponent},{path:「detail /:id」,component:HeroDetailComponent}]} –
我得到一個 _core .umd.js:3462 EXCEPTION:未捕獲的(在承諾):錯誤:無法匹配任何路線:「細節/ 11'_ 爲什麼需要,如果已經有上述定義的英雄路徑來定義一個空的路徑? 英雄是不使用這個孩子方法英雄路... –