Skip to content

Instantly share code, notes, and snippets.

@thekage91
Last active March 2, 2020 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thekage91/366dd632d52e4136abbfe940d1e8f2c5 to your computer and use it in GitHub Desktop.
Save thekage91/366dd632d52e4136abbfe940d1e8f2c5 to your computer and use it in GitHub Desktop.
Angular Pipe to trust safe url
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