Skip to content

Instantly share code, notes, and snippets.

@aih
Forked from zomdar/safe-html.pipe.ts
Created August 23, 2019 21:21
Show Gist options
  • Save aih/1ce241828df63387a50ad87e8773f07c to your computer and use it in GitHub Desktop.
Save aih/1ce241828df63387a50ad87e8773f07c to your computer and use it in GitHub Desktop.
safeHtml pipe
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from "@angular/platform-browser";
@Pipe({
name: 'safeHtml'
})
export class SafeHtmlPipe implements PipeTransform {
constructor(private _sanitizer:DomSanitizer) {}
transform(html: string): SafeHtml {
return this._sanitizer.bypassSecurityTrustHtml(html);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment