import { Component, SecurityContext } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
@Component({
selector: 'demo-alert-dynamic-html',
templateUrl: './dynamic-html.html'
})
export class DemoAlertDynamicHtmlComponent {
alerts: any = [
{
type: 'success',
msg: `Well done! You successfully read this important alert message.`
},
{
type: 'info',
msg: `Heads up! This alert needs your attention, but it's not super important.`
},
{
type: 'danger',
msg: `Warning! Better check yourself, you're not looking too good.`
}
];
constructor(sanitizer: DomSanitizer) {
this.alerts = this.alerts.map((alert: any) => ({
type: alert.type,
msg: sanitizer.sanitize(SecurityContext.HTML, alert.msg)
}));
}
}