I am using Angular ngToast. I am trying to show only one toast at a time. The previously displayed toast should be hidden before displaying a new toast.There should be only one toast at a time. I tried be specifying maxNumber but doesn't work.
ngToast.create({
className: 'info',
content: ' New Toast',
maxNumber: 1
//autoDismiss: true,
//maxOpened: 1
//timeout: 500,
//preventDuplicates: true,
//preventOpenDuplicates: true
//dismissOnClick:true
//clickToClose: true
});
Here is a fiddle that might help you: https://jsfiddle.net/774a9dq4/5/
The only difference here is that before calling the new instance of toast object, just call the dismiss() which will be dismissing ALL the toast instances in DOM.
ngToast.dismiss();
ngToast.create({
content:'I am unique <3'
});
Hope this may help:
Use the ngToast.dismiss() to clear all toasts.
Or
ngToast.dismiss(yourToastMsg) to clear a particular toast.
For more details refer to this link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With