In Angular, how do you determine the active route?
375
With the new Angular router, we can add a [routerLinkActive]="['your-class-name']"
attribute to all your links:
<a [routerLink]="['/home']" [routerLinkActive]="['is-active']">Home</a>
Or the simplified non-array format if only one class is needed:
<a [routerLink]="['/home']" [routerLinkActive]="'is-active'">Home</a>
Or an even simpler format if only one class is needed:
<a [routerLink]="['/home']" routerLinkActive="is-active">Home</a>