Skip to content

Instantly share code, notes, and snippets.

@ozzpy
Created December 8, 2021 14:08
Show Gist options
  • Save ozzpy/7fd9cb2ee44d503fda7fb34f400f035d to your computer and use it in GitHub Desktop.
Save ozzpy/7fd9cb2ee44d503fda7fb34f400f035d to your computer and use it in GitHub Desktop.
video-ts
import {Pipe, PipeTransform, SecurityContext} 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);
// error
//return this.sanitizer.sanitize(SecurityContext.URL, url);
}
}
<ng-container *ngIf="_configHome.home4.top.data.length == 1">
<iframe id="home4_iframe"
width="100%"
height="315"
frameborder="0"
[src]="_configHome.home4.top.data[0].url|safe"
title="YouTube video player"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
<ng-container *ngIf="_configHome.home4.top.data[0].link != null && _configHome.home4.top.data[0].link.length > 0">
<ion-button color="tertiary" expand="full" (click)="openLink(_configHome.home4.top.data[0].link)">Ver mais...</ion-button>
</ng-container>
</ng-container>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment