Angular2 add class when route is inactive

后端 未结 1 831
难免孤独
难免孤独 2021-01-12 15:27

Angular2 has a routerLinkActive directive which adds class to the element if the route is active. I want to add a class when route is inactive

相关标签:
1条回答
  • 2021-01-12 15:59
    <a routerLink="/user/bob" routerLinkActive #rla="routerLinkActive" [ngClass]="rla.isActive ? 'classIfActive' : 'classIfNotActive'">
    </a>
    
    0 讨论(0)
提交回复
热议问题