Answers for "Sanitize Html , stop remove style when innerHtml angular"

0

Sanitize Html , stop remove style when innerHtml angular

//Pipe
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);
  }
}

// HTML
<div [innerHtml]="html | safeHtml"></div>
Posted by: Guest on August-03-2021

Browse Popular Code Answers by Language