Home > database >  Angular - Active route still appears when I am not on the route
Angular - Active route still appears when I am not on the route

Time:06-14

Here is an example of what I have: enter image description here enter image description here

Does anyone know how I can fix this?

CodePudding user response:

You are running in to the problem that angular router resolves / as an path, and that exists in /Catalog.

You can use [routerLinkActiveOptions]="{exact: true}" on your login a tag, making it.

<a routerLinkActive="active" 
   [routerLinkActiveOptions]="{exact: true}"
   routerLink="">Login</a>

Forked stackblitz

  • Related