How To Render A Raw HTML On Angular
I've tried to render a raw HTML using innerHTML, as bellow: This HTML has style in line, but it does n
Solution 1:
Potentially, you need a SafePipe for your html as your browser does not trust injected html code:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'safePipe'})
export class safePipe implements PipeTransform {
constructor(protected sanitizer: DomSanitizer):{}
transform(value) {
return this.sanitizer.bypassSecurityTrustHtml(value);
}
}
usage in HTML:
<span [innerHtml]="potentiallyNotSafeHtmlCode | safePipe"></span>
Post a Comment for "How To Render A Raw HTML On Angular"