A client asks you to highlight the currently active page link in the navigation menu. How would you achieve this in Angular?

  • By using the routerLinkActive directive and applying it to the navigation menu items with a CSS class.
  • By using JavaScript to detect the active route and apply a CSS class to the corresponding navigation menu item.
  • By manually updating the active page link in the navigation component whenever a route changes.
  • By creating a custom Angular directive to handle active link highlighting.
To highlight the currently active page link in the navigation menu in Angular, you should use the routerLinkActive directive. This directive is applied to the navigation menu items and automatically adds a CSS class when the corresponding route is active. The other options are either incorrect or involve more manual and error-prone approaches.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *