【发布时间】:2019-01-29 06:19:43
【问题描述】:
我需要将来自 youtube 的视频放在我的网站中,但 URL 是一个变量,我创建了一个可以放置的管道,但不起作用。
这是我在 HTML 文件中的代码
<iframe width="670" height="348" [src]=" video | video" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
我的管道代码是这样的
export class VideoPipe implements PipeTransform {
constructor (private domSanitizer:DomSanitizer ){ }
transform(url: string): any {
return this.domSanitizer.bypassSecurityTrustResourceUrl( url );
}
}
但是当我尝试输入视频 URL 时,我得到了错误。
我在开关盒中分配 URL 视频
case 'marketing':{
this.bodyClass="background-marketing-text";
this.btnClass="btnMarketing";
this.video="https://www.youtube.com/watch?v=TTyFV-qhQtQ";
break;
}
【问题讨论】:
标签: html angularjs typescript pipe