Skip to content

Instantly share code, notes, and snippets.

@MurhafSousli
Last active August 16, 2023 04:08
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MurhafSousli/3d2ddb777c8ce88e2400bd93f694cd3b to your computer and use it in GitHub Desktop.
Save MurhafSousli/3d2ddb777c8ce88e2400bd93f694cd3b to your computer and use it in GitHub Desktop.
HTML Dom Sanitizer Pipe
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
@Pipe({
name: 'sanitizeHtml'
})
export class HtmlSanitizerPipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer) {
}
transform(value: string): SafeHtml {
return this.sanitizer.bypassSecurityTrustHtml(value);
}
}
@MurhafSousli
Copy link
Author

Angular service calls the service that bypass the content DomSanitizer, assuming you know what you're doing! the gist name was just a short name for a pipe that uses the DomSanitizer to bypass html content.

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