You can leverage DomSanitized
to avoid it.
The easiest way is to create custom pipe like:
import { DomSanitizer } from '@angular/platform-browser'
import { PipeTransform, Pipe } from "@angular/core";
@Pipe({ name: 'safeHtml'})
export class SafeHtmlPipe implements PipeTransform {
constructor(private sanitized: DomSanitizer) {}
transform(value) {
return this.sanitized.bypassSecurityTrustHtml(value);
}
}
So you can use it like:
<div [innerHtml]="html | safeHtml"></div>
Plunker Example
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…