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

Viewed 53

Here is an example of what I have: my code.

I tried to make my LoginComponent to be my "empty" path, and to appear without a specific router name in my URL, and it is working. Although, he still appears as the activeroute, I even putted pathMatch: 'full', but didn't work...

enter image description here enter image description here

Does anyone know how I can fix this?

1 Answers

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