我有这个HTML iframe:
<iframe
class="embed-responsive-item"
[src]="displayedVideo?.url"
allowfullscreen
></iframe>其中,在TS中displayedVideo是一个对象:
export class DisplayedVideo {
title = '';
url: SafeResourceUrl;
date = '';
}在我的服务中,我有获得youtube电影的方法,所以我可以在我的页面上显示它:
getYoutubeEmbedUrl(videoId: string): SafeResourceUrl {
const url = `https://www.youtube.com/embed/${videoId}`;
return this.sanitizer.bypassSecurityTrustResourceUrl(url);
}问题是:每次我使用此函数更改视频URL时,我的应用程序都会“转到”下一页,因此“上一页”按钮只是将视频URL更改为URL上一页。
场景:我调用getYoutubeEmbedUrl() 10次(当然,通过赋值,这只是一个服务),所以我必须单击“返回”浏览器按钮10次,才能返回到实际的上一页。尽管使用了DomSanitizer,我还是得到了“在资源地址上下文中使用了不安全的值”。
感谢你的帮助
发布于 2021-04-18 23:07:53
找到了可行的解决方案:link
gfdevelop的回答很有帮助。对我来说,这看起来像是一个角度错误:)
https://stackoverflow.com/questions/67143585
复制相似问题