我目前有一些路线
<ul class="">
<li class="">
<a [routerLinkActive]="['active']"
[routerLink]="['/user/traffic/graph']" class="">
Traffic
</a>
</li>
</ul>
路线
const trafficRoutes: Routes = [
{
path: '', component: TrafficComponent, children: [
{ path: '', redirectTo: 'graph' },
{ path: 'graph', component: GraphComponent},
{ path: 'alerts', component: AlertComponent}
]
},
];
当我导航到GraphComponent
时,路由器链接被激活,但当我导航到AlertComponent
时,它不活动。
我想让路由器链接处于活动状态。即使我导航到AlertComponent
如何实现?
答案 0 :(得分:0)
我的坏。一个新秀的错误。更改为模块URL可修复所有内容
<ul class="">
<li class="">
<a [routerLinkActive]="['active']"
[routerLink]="['/user/traffic/']" class="">
Traffic
</a>
</li>
</ul>