boris-jenicek / ngx-awesome-popup

🚀 Open-source - The world's easiest, most powerful Angular dialog modal framework. Confirmation box, Alert box, Toast notification, Cookie banner, Any dynamic dialog content.

Home Page:https://boris-jenicek.github.io/ngx-awesome-popup/#/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Close All on Page Changes

queejie opened this issue · comments

Thanks for this fantastic package. My app pops up info toast message for some pages, and leaves them up for N seconds. However, if the user goes to another page, the message remains displayed. Is there a way to hide all existing messages, or some sort of handle to grab that will allow for closing when changing components?

	public postInstructions(message: string, durationMs: number) {
		const newToastNotification = new ToastNotificationInitializer();
		newToastNotification.setTitle('FYI');
		newToastNotification.setMessage(message);
		newToastNotification.setConfig({
			autoCloseDelay: durationMs,
			textPosition: 'left',
			layoutType: DialogLayoutDisplay.INFO,
			toastUserViewType: ToastUserViewTypeEnum.STANDARD,
			animationIn: AppearanceAnimation.SLIDE_IN_DOWN,
			animationOut: DisappearanceAnimation.SLIDE_OUT_LEFT,
			toastPosition: ToastPositionEnum.TOP_LEFT,
		});
		newToastNotification.openToastNotification$();
	}

This solution works, although I'm sure it isn't the best idea:

	ngOnDestroy() {
		const msgBoxes = document.querySelectorAll('.toast-wrapper');
		for (let i = 0; i < msgBoxes.length; i++) {
			msgBoxes[i].remove();
		}
	}

sorry, not at the moment.