Angular · Junior · Question 57 of 75
How do you highlight the menu link for the current route?
<a routerLink="/users" routerLinkActive="active">Users</a>- ✓Correct answer: Add
routerLinkActivewith the CSS class to apply - 2Compare
window.location.hrefin every component - 3Use
[class.active]="true"
Explanation
The directive adds the class while the link's route is active. [routerLinkActiveOptions]="{ exact: true }" prevents / from matching every page.