Last active
August 16, 2023 04:08
-
-
Save MurhafSousli/3d2ddb777c8ce88e2400bd93f694cd3b to your computer and use it in GitHub Desktop.
HTML Dom Sanitizer Pipe
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
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 theDomSanitizer
to bypass html content.