Topic: Template or HTML in Toast
MikeOnline priority asked 4 years ago
I am trying to use a Toast / Notification with a custom message using HTML, the Angular docs (https://mdbootstrap.com/docs/angular/advanced/notifications/#docsTabsAPI) for notations list an option of "enableHtml" but how does this work? and is this the right option to allow custom html in the toast/notification message?
Can it be done?
Konrad Stępień staff answered 4 years ago
Hi @MikeOnline,
Yes, you can provide HTML like this:
HTML
<a mdbBtn color="info" class="waves-light" (click)="showInfo()" mdbWavesEffect>Info message</a>
TS
showInfo() {
this.toastrService.info('<b>Success</b> message', '', { enableHtml: true });
}
But remember, this option is "unsafe" because you can provide too many elements along with styles which can spoil the notification view
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Angular
- MDB Version: 9.3.1
- Device: Laptop
- Browser: *ium
- OS: Windows 10
- Provided sample code: No
- Provided link: Yes