Last active
December 13, 2019 01:42
-
-
Save schmidt1024/d1c635a9d8ca6d2d8804a16822b72e4e 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
based on https://stackoverflow.com/a/40942179/4243279