Solvedangular Router can't navigate when exception occurrs

I'm submitting a ... (check one with "x")

[V ] bug report => search github for a similar issue or PR before submitting

Current behavior

Router.Navigate fails to navigate when exception occurs
Expected behavior

Router is able to navigate even though application exception occurred
Minimal reproduction of the problem with instructions

I have created a plunker here, you can comment out line 16 of ContactComponent to see the no exception scenario, and enable it to see the error scenario. I purposely created this exception to test out exception navigation, I expect my custom error handler GlobalErrorService is able to navigate the page to ErrorComponent, but that's not happening

https://embed.plnkr.co/HhYYHnqAOHzFAvKc7o58/

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

Windows

  • Angular version: 4.0.2
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5]

  • Node (for AoT issues): node --version =

15 Answers

✔️Accepted Answer

Yes, thank you, I didn't think to use the zone... silly me !

For future readers :

inside your error handler service (think to inject NgZone) :

this.zone.run(()=>this.router.navigate(["/error"]))

Other Answers:

More Issues: