Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在Angular 8中绑定youtube链接?_Html_Angular_Bootstrap 4 - Fatal编程技术网

Html 在Angular 8中绑定youtube链接?

Html 在Angular 8中绑定youtube链接?,html,angular,bootstrap-4,Html,Angular,Bootstrap 4,我有视频问题,链接在数组中,绑定不起作用 <div class="card mb-4" *ngFor="let clip of clips"> <div class="embed-responsive embed-responsive-16by9"> <iframe class="embed-responsive-item" [src]="clip.src"></iframe>

我有视频问题,链接在数组中,绑定不起作用

<div class="card mb-4" *ngFor="let clip of clips">
              <div class="embed-responsive embed-responsive-16by9">
                  <iframe class="embed-responsive-item" [src]="clip.src"></iframe>
                </div>
              <div class="card-body">
              <h2 class="card-title">{{clip.src}}</h2>
              <p class="card-text">{{clip.description}}</p>
            </div>

{{clip.src}

{{clip.description}


如果我绑定像“http://”这样的链接,就可以了。如果像
[src]=“clip.src”或src=“{{clip.src}}”
这样的绑定不起作用。如何从对象到绑定使用src?

您所拥有的看起来应该可以工作。您可能需要创建一个safeUrl管道来绕过DOM Sanitizer

这是一篇关于这方面的好文章


简而言之,Angular试图保护您的用户免受XSS攻击。您知道链接是安全的,但是Angular不安全,因此它将其从标记中剥离以保护用户。绕过DOM Sanitizer会阻止Angular执行此操作。

clip.src的值是多少?您在控制台中看到一个与安全相关的错误?clip.src是youtube linkAngular Components正在版本9中添加一个youtube组件,目前尚未发布,但如果我的评论回答了您的问题,您可以尝试一下,请把它标记为正确的。