Created
September 17, 2018 11:05
-
-
Save sankarseran/f2e1378fdad81a0e95dafbeedc94e1c5 to your computer and use it in GitHub Desktop.
This spinet for loading the component, While the route path is changed but the component is not rendered.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ErrorHandler, Injectable, Injector, NgZone } from '@angular/core'; | |
import { Router } from '@angular/router'; | |
@Injectable() | |
export class AppErrorHandler implements ErrorHandler { | |
constructor(private injector: Injector) { } | |
handleError(error: any): void { | |
const routerService = this.injector.get(Router); | |
const ngZone = this.injector.get(NgZone); | |
ngZone.run(() => { | |
routerService.navigate(['/error'], { skipLocationChange: true }); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment