It is possible to find many examples showing how to navigate between components using a button or a routerLink in angular 2. What I want to do is to navigate to a certain component when an error occurs, without user action. Like this:
class MyErrorHandler implements ErrorHandler {
handleError(error) {
this.router.navigate(['/pagenotfound']);
}
}
But it is not possible to initialize a Router object in MyErrorHandler constructor. Is there any way to work around this issue and create an auto navigate system?