Skip to content

Instantly share code, notes, and snippets.

@sankarseran
Created September 17, 2018 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sankarseran/f2e1378fdad81a0e95dafbeedc94e1c5 to your computer and use it in GitHub Desktop.
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.
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