Skip to content

Instantly share code, notes, and snippets.

@MarvinZ
Created June 9, 2017 06:19
Show Gist options
  • Save MarvinZ/37d53c83e332e99cf04dbbbdc1b8a1ff to your computer and use it in GitHub Desktop.
Save MarvinZ/37d53c83e332e99cf04dbbbdc1b8a1ff to your computer and use it in GitHub Desktop.
SafePipe
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer} from '@angular/platform-browser';
@Pipe({ name: 'safe' })
export class SafePipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer) {}
transform(url) {
return this.sanitizer.bypassSecurityTrustResourceUrl(url);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment