Reputation: 7877
I'm redirecting to a new route after logging-in via this:
this.router.navigate(['/firstPage']);
When my application is loaded for the first time, this redirection doesn't happen automatically after login. But if the user logs out and logins, then this redirection happens.
**My question is: How to debug why it's not getting redirected, despite this line getting executed? **
I mean, how to debug the issue when no error is being shown and control is passing over this line (as confirmed via debugger)?
Upvotes: 5
Views: 4142
Reputation: 149
I am not able to comment yet so I will post it as answer.
You could try to enable enableTracing
in router module which will log all navigation events to console.
imports: [
RouterModule.forRoot(
routes,
{ enableTracing: true } // <-- debugging purposes only
)]
At first they might seem to be a bit overwhelming but they can be useful in your case since you will be able to see that for example some guard stopped navigation
Upvotes: 8