【问题标题】:how to make parent state active(i.e., add active class) when child is active当孩子处于活动状态时如何使父状态处于活动状态(即添加活动类)
【发布时间】:2017-09-27 12:01:33
【问题描述】:

我目前有一些路线

<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

如何实现?

【问题讨论】:

    标签: angular typescript angular-router


    【解决方案1】:

    我的错。一个菜鸟的错误。更改为模块 URL 可以解决所有问题

    <ul class="">
      <li class="">
        <a [routerLinkActive]="['active']"
           [routerLink]="['/user/traffic/']" class="">
           Traffic
        </a>
      </li>
    </ul>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-13
      • 1970-01-01
      • 1970-01-01
      • 2019-09-16
      • 2016-06-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多