我想使用来自 youtube 和其他类似平台的 iframe - 但我不知道如何使用变量作为我的源。
我已经搜索过了,但我得到的答案没有奏效。
所以这里是 iframe:
<div class="right">
<h2>Associated Pictures/Media Files</h2>
<p>Here we will display either Infos, Fotos, Videos, Music or even interative content.</p>
<div style="padding: 2%;">
<iframe
width="100%"
height="315"
src="https://www.youtube.com/embed/Q7hmXN714RQ"
frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen>
</iframe>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我唯一想要的是在这里使用这个变量:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
source = 'https://www.youtube.com/embed/Q7hmXN714RQ';
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试以各种方式做到这一点时 - 例如:
src="{{source}}"
Run Code Online (Sandbox Code Playgroud)
这根本不起作用:(
有谁知道如何正确地做到这一点?我找不到针对此问题的适当解决方案。