diff --git a/ui-ngx/src/app/shared/components/toast.directive.ts b/ui-ngx/src/app/shared/components/toast.directive.ts index ac3d284474..773a6d298e 100644 --- a/ui-ngx/src/app/shared/components/toast.directive.ts +++ b/ui-ngx/src/app/shared/components/toast.directive.ts @@ -135,8 +135,10 @@ export class ToastDirective implements AfterViewInit, OnDestroy { notification: notificationMessage, panelClass, destroyToastComponent: () => { - this.viewContainerRef.detach(0); - this.toastComponentRef.destroy(); + if (this.toastComponentRef) { + this.viewContainerRef.detach(0); + this.toastComponentRef.destroy(); + } } }; const providers: StaticProvider[] = [