I want to style the css and add class when a link is active using routerLinkActive. I have tried in bootstrap and it works, but then when I got the custom CSS from the front end developer, it won't add the class that states that it is active, even when the route url is match the routeLink.
I am a bit frustated and have no idea what is wrong. I expect it will add class menu-active in the anchor when the route is active.
here's my code:
sidebar.component.html
<li class="menu-parent">
<a class="menu-item" routerLink="/dashboard" routerLinkActive="menu-active">
<i class="ti ti-anchor"></i>
<span class="menu-text">Dashboard</span>
</a>
</li>
I have tested like the code below, referenced from this question. I expect the i showed because the routerlink is active, but it doesn't, even when I am in the http://localhost:4200/dashboard.
<li class="menu-parent">
<a class="menu-item" routerLink="/dashboard" routerLinkActive #rla="routerLinkActive">
<i class="ti ti-anchor" *ngIf="rla.isActive"></i>
<span class="menu-text">Dashboard</span>
</a>
</li>
Hope someone could clear my frustration. Thank you.
Update:
The class is not even added when I inspect the element. Here's the screenshot of it: