In Angular(2/4/5), Router Link Active is used to identify whether a route is active or not. Based on this we can control the CSS class
Example:
<ul class="nav navbar-nav">
<li><a routerLink="/" routerLinkActive="menu-active">Home</a></li>
<li><a routerLink="/about" routerLinkActive="menu-active" >About</a></li>
<li><a routerLink="/contact" routerLinkActive="menu-active" >Contact</a></li>
</ul>
In Above example will add the menu-active
class if the route found in routerLink
matches the current route.