- Home
- Forum
- Angular - EJ 2
- Appending multiple error messages in existing error toast
Appending multiple error messages in existing error toast
Attachment: error_7f00e459.zip
Thanks for the update,
Please get back to us if you need any further assistance.
Regards,
Indrajith
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
- 5 Replies
- 4 Participants
- Marked answer
-
AM Aditya Murthy
- Nov 25, 2020 08:09 AM UTC
- Sep 14, 2022 12:22 PM UTC