angularngx-toastr

How to hide ngx-toaster programmatically?


I use ngx-toaster with disableTimeOut true. So it won't hide automatically. But now I won't to hide it programmatically, when user leaving the page(inside the ngOnDestroy method). How can I do it?

this.toastr.error(message, status, {disableTimeOut: true});

Solution

  • You just have to call the .clear() method and pass the toastId If needed

     this.toastr.clear(this.toastRef.toastId);
    

    STACKBLITZ DEMO