Last active
February 21, 2018 07:14
-
-
Save nezhar/79ad48078ed1d941710a3e106b79c61a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 } from '@angular/platform-browser'; | |
| @Pipe({ | |
| name: 'safe' | |
| }) | |
| export class SafePipe implements PipeTransform { | |
| constructor(private sanitizer: DomSanitizer) { } | |
| transform(value: any, args?: any): any { | |
| if (value) { | |
| return this.sanitizer.bypassSecurityTrustResourceUrl(value); | |
| } | |
| } | |
| } |
This file contains hidden or 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
| **Inside tag:** `<iframe width="560" height="315" [src]="getVideoURL(video.embed) | safe"></iframe>` | |
| **Interpolation:** `{{ getVideoURL(video.embed) | safe }}` | |
| **Note:** Pipe can be generate using angular cli: *ng g pipe path/name* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment