How to use routerLinkActive with empty routerLink

╄→尐↘猪︶ㄣ 提交于 2019-12-06 07:01:39

问题


I have the following tab bar links and the first one is supposed to be empty:

<nav md-tab-nav-bar>
          <a md-tab-link [routerLink]="'./'" 
             routerLinkActive #rla="routerLinkActive" [active]="rla.isActive">
            My tab
          </a>
...
</nav>

The link works fine but the active state is not triggered.

What is the proper way to handle empty routerlink for the tab to be activated?


回答1:


Try this instead

<a [routerLink]=" ['./'] "
    routerLinkActive="active" [routerLinkActiveOptions]= "{exact: true}">
    My tab
</a>

https://angular.io/docs/ts/latest/api/router/index/RouterLinkActive-directive.html



来源:https://stackoverflow.com/questions/43374872/how-to-use-routerlinkactive-with-empty-routerlink

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