1

I have links as "Register" on login page & "Login" on register page. I used the code below to navigate:

<p>Not a member? <a [routerLink]="['/register']">Register</a></p>

and

<p>Already have an account? <a routerLink="/login">Login</a></p>

Code works perfectly fine if the user is not already logged in. User can navigate to both pages back and forth. But once the user is logged in, and logs out it cannot navigate to Register page anymore (without refreshing the page). The route changes to /register but the page is not loaded.

I have <router-outlet> </router-outlet> on app.component.html & also tried some other solutions from previous questions but nothing's working so far.

SaraJ
  • 43
  • 1
  • 7

1 Answers1

0

Try this:

<a routerLink="/register">Register</a>

That might fix it.

Also try checking your console logs for errors. An error in the console can stop the router from working.

However, the most likely reason is that a guard is blocking it. Check your guard logic (this happened to me recently).

danday74
  • 52,471
  • 49
  • 232
  • 283
  • This didnt work either: Register, no errors on console log. {path: 'login', component: LoginComponent, data: {title: 'Login'}}, { path: 'register', component: RegisterComponent, data: { title: 'Register' } }, I have also removed the guards from route configurations – SaraJ Dec 06 '21 at 13:03