我现在有一些路线
<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
如何做到这一点?
最佳答案
我的错。新手犯的错误。更改模块url可以修复所有问题
<ul class="">
<li class="">
<a [routerLinkActive]="['active']"
[routerLink]="['/user/traffic/']" class="">
Traffic
</a>
</li>
</ul>