为什么 this jsfiddle不管用?我无法获取 videoId
的值。如果我从模块中删除 ngRoute
那么它工作正常。
最佳答案
你需要像这样使用ng-src
:
<div ng-controller="AppController">
<h1>{{videoID}}</h1>
<iframe class="youtube-player" type="text/html" width="auto"
height="auto" ng-src="{{videoID}}"
allowfullscreen="" frameborder="0"> </iframe>
</div>
和
var app = angular.module('my-app', []);
app.controller('AppController', function ($scope, $sce) {
$scope.videoID = $sce.trustAsResourceUrl('http://www.youtube.com/embed/C0DPdy98e4c');
});
参见 this documentation .
关于javascript - 带 iframe 的 AngularJs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19312045/