I have an angular (4.2.5) app, and at some point in my code, I do this :
this._appService
.post('/createhero/save', opts)
.subscribe(
(resData: any) =>
{
this._router.navigate(['home']);
}
);
The router call to navigate()
doesn't work - nothing happens. I enabled route debug, and this is what I get :
So the navigation is canceled without given reason. In others components, I have the same kind of navigate()
(some in observable callbacks too) which works well. The route /home
works as well.
I'm starting to run out of ideas, and I don't even know why the navigate()
won't work in this case.
Had similar issue, reason
really doesn't help does it :)
What my issue was, was that the route I tried to navigate had a guard on its own which subscribed to observable and since I already gave value to it, the initial value of observable was false
and since route was blocked, navigation was canceled.
Can it be that some other guard is blocking the route and canActivate()
gives out true
/false
while depending on your query result but not actually waiting for the result?
Hope this helps a bit at debugging :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With