Skip to content

Instantly share code, notes, and snippets.

@schmidt1024
Last active December 13, 2019 01:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save schmidt1024/d1c635a9d8ca6d2d8804a16822b72e4e to your computer and use it in GitHub Desktop.
Save schmidt1024/d1c635a9d8ca6d2d8804a16822b72e4e 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);
}
}
@schmidt1024
Copy link
Author

schmidt1024 commented Aug 24, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment