Apply a directive when routerLinkActive is true

752 views
Skip to first unread message

Mathieu Bourmaud

unread,
Apr 11, 2017, 1:20:13 PM4/11/17
to angular-material2
Hello, 

I currently have two routes, I would like to replace the md-button by a md-raised-button when the link is active. Do you think it's possible ? I can't find any solution. Thanks a lot guys.

<a md-button routerLink="/" routerLinkActive="toolbar-active" [routerLinkActiveOptions]="{exact: true}">
Home
</a>
<a md-button routerLink="/todos" routerLinkActive="toolbar-active" [routerLinkActiveOptions]="{exact: true}">
Todos
</a>

Steven

unread,
Apr 11, 2017, 4:33:23 PM4/11/17
to angular-material2


This is how I add the disabled attribute when the route is active. I suspect your use case can be done the same way.

<button md-raised-button [routerLink]="['stuff']" routerLinkActive #rla="routerLinkActive" [disabled]="rla.isActive">Map</button>
Reply all
Reply to author
Forward
0 new messages