hello, you can use if conditions like that!
Hi Hussein,
Now, toast have a built-in utility function to render the toast on the go, we have prepared a sample for your reference.
Code Snippet:
import { ToastUtility, Toast } from '@syncfusion/ej2-notifications'; . . . export class AppComponent { public toastObj: Toast; public showToast(args): void { if (args.target.classList.contains('e-info')) { this.hideToast(); this.toastObj = ToastUtility.show( 'Please read the comments carefully', 'Information', 20000 ); } else if (args.target.classList.contains('e-success')) { this.hideToast(); this.toastObj = ToastUtility.show( 'Your message has been sent successfully', 'Success', 20000 ); } else if (args.target.classList.contains('e-warning')) { this.hideToast(); this.toastObj = ToastUtility.show( 'There was a problem with your network connection', 'Warning', 20000 ); } else if (args.target.classList.contains('e-danger')) { this.hideToast(); this.toastObj = ToastUtility.show( 'A problem has been occurred while submitting the data', 'Error', 20000 ); } } public hideToast(): void { if (this.toastObj != null && this.toastObj != undefined) { this.toastObj.hide('All'); } } } |
Sample: https://stackblitz.com/edit/angular-qdruvr?file=app.component.ts,app.component.html
Documentation: https://ej2.syncfusion.com/angular/documentation/toast/toast-services/
Regards,
Revanth