I have set in app-routing.module.ts
{path: 'profile:/userId', component: ProfileComponent, canActivate:[AuthGuard]},
// In case the address doesn't match our paths ,redirects to login
{path: '**', redirectTo: 'login'}
any uknown path word will to redirect me to the login page, but this also happening when i click on profile on the navbar button.
Instead of getting to the profile.componennt.html view it goes to log in. Any idea why is that happening?
<a [routerLink]="'/profile/' + currentUser.id" class="nav-link">Profile</a>
For two reasons it might redirect to the login page:
1- Your
AuthGuardfails and it redirects to the login page2- The path is not correct in routes