Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use routerLinkActive with empty routerLink

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?

like image 524
doorman Avatar asked Apr 12 '17 16:04

doorman


1 Answers

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

like image 78
Dmitrij Kuba Avatar answered Sep 28 '22 02:09

Dmitrij Kuba