Skip to content

Instantly share code, notes, and snippets.

@howardpanton
Forked from schmidt1024/sanitizehtml.pipe.ts
Created April 17, 2018 11:10
Show Gist options
  • Save howardpanton/400fc988af33d6ed894e6c17091d2f4c to your computer and use it in GitHub Desktop.
Save howardpanton/400fc988af33d6ed894e6c17091d2f4c to your computer and use it in GitHub Desktop.
angular 4 pipe for bypass security trust html
// <div [innerHTML]="your.value | sanitizeHtml" ></div>
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
@Pipe({name: 'sanitizeHtml'})
export class SanitizeHtmlPipe implements PipeTransform {
constructor(private _sanitizer:DomSanitizer) {
}
transform(v:string):SafeHtml {
return this._sanitizer.bypassSecurityTrustHtml(v);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment