2

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});
Prashant Pimpale
  • 10,349
  • 9
  • 44
  • 84
Sameera K
  • 1,298
  • 1
  • 17
  • 26

2 Answers2

6

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

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

STACKBLITZ DEMO

Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
3

Use clear()

this.toastr.clear()
Chenna
  • 2,383
  • 3
  • 20
  • 36