Last active
March 2, 2020 15:35
-
-
Save thekage91/366dd632d52e4136abbfe940d1e8f2c5 to your computer and use it in GitHub Desktop.
Angular Pipe to trust safe url
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, SafeUrl } from "@angular/platform-browser"; | |
@Pipe({ | |
name: 'safe' | |
}) | |
export class SafePipe implements PipeTransform { | |
constructor(private sanitizer: DomSanitizer) { } | |
transform(url: string): SafeUrl { | |
return this.sanitizer.bypassSecurityTrustUrl(url); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment