Angular2 add class when route is inactive

南楼画角 提交于 2020-01-02 05:29:08

问题


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. Is there a way to do this?


回答1:


<a routerLink="/user/bob" routerLinkActive #rla="routerLinkActive" [ngClass]="rla.isActive ? 'classIfActive' : 'classIfNotActive'">
</a>


来源:https://stackoverflow.com/questions/41982000/angular2-add-class-when-route-is-inactive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!