First create Ana Pipe.
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
@Pipe({
name: 'sanitizer',
})
export class SanitizerUrlPipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer) {}
transform(value: string, args: any = 'SafeURL'): SafeUrl | SafeHtml {
if (args == 'SafeHtml') {
return this.sanitizer.bypassSecurityTrustHtml(value);
}
}
}
After UseThen, use the pipe in your HTML template like this.
<div [innerHtml]="data | sanitizer : 'SafeHtml'"></div>