Open Zetanova opened 3 years ago
I stumbled upon the same issue and found a fix on the Angular2-Toaster
project page.
They describe that you should run the call within an ngZone.run(...)
block.
export class AppErrorHandler implements ErrorHandler {
constructor(
private toasterService: ToasterService,
private ngZone : NgZone) { }
handleError(error: any): void {
this.ngZone.run(() => {
this.toasterService.pop('error', "Error", error);
});
}
}
This should probably adapted slightly and just be added to the official documentation and we are good to go.
If an message gets queued in the the angular ErrorHandler.handleError(error: any) method, the notification will not get rendered until some other page change.
Workaround: To display the message instantly a force change detection can be triggered with
(<any>this.notifierContainer).changeDetector.detectChanges();