javascript - Apply CSS to active router link [Angular 2] -
this question has answer here:
- how highlight current menu item? 29 answers
i apply special css style properties active router links:
<a [routerlink]='link'>{{name}}</a>
here tried far (using default router-link-active class):
.router-link-active { color: #000; font-weight: bold; }
it doesn't work , don't understand why.
currently angular 2 has built in attribute can use on link used [routerlink]
routerlinkactive
need have:
<a [routerlink]='link' routerlinkactive="router-link-active">{{name}}</a>
and recognize route current active route , apply router-link-active class.
note:
for using routerlink on tags other a
tags, (personally using on button) routerlinkactive
doesn't work should work on next release of router - https://github.com/angular/angular/issues/9755
Comments
Post a Comment