Topic: MDB Angular: close an alert before open a new one

diegomoreno_2000 pro asked 1 year ago


Expected behavior Programatically close or hide an alert before open a new one

Actual behavior Many alerts are shown at the same time. When stacked option is not used, the newest overlaps the previous one

Resources (screenshots, code snippets etc.) I'm using the docs samples


Arkadiusz Idzikowski staff answered 11 months ago


The notification service returns a MdbNotificationRef which gives you access to the currently open alert instance. You can use it to close the current alert before opening a new one:

  openAlert(): void {
    if (this.notificationRef) {
      this.notificationRef.close();
    }

    this.notificationRef = this._notificationService.open(YourComponent);
  }

diegomoreno_2000 pro commented 11 months ago

Thank you, it works.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • User: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: MDB5 4.0.0
  • Device: PC
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No