-
-
Save howardpanton/400fc988af33d6ed894e6c17091d2f4c to your computer and use it in GitHub Desktop.
angular 4 pipe for bypass security trust html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <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