App.js:AngularJS白名單YouTube網址iframe的
(function() {
var app = angular.module("RandomAnimeApp", []).config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist([
'self',
'*://www.youtube.com/**'
]);
});
}());
控制器:
(function() {
var app = angular.module("RandomAnimeApp");
var ListController = function($scope, $http, $window, $timeout, $sce) {
//stuff and things
};
app.controller("ListController", ["$scope", "$http", "$window", "$timeout", "$sce", ListController])
}());
查看:
<iframe itemprop="trailer" src="about:blank" data-ng-src="https://www.youtube.com/embed/{{ a.source }}?wmode=opaque&showinfo=0&autohide=1&rel=0&iv_load_policy=3&enablejsapi=1"></iframe>
哪裏a.source等於一個YouTube視頻ID 。
無論我嘗試什麼,我都不斷收到iframe的「錯誤:$ interpolate:noconcat 多個表達式」錯誤。我錯過了什麼?
確切的錯誤地址:https://docs.angularjs.org/error/ $內插/ noconcat P0 = HTTPS:?%2F%2Fwww.youtube.com%2Fembed%2F%7B%7B%20a.source%20%7D%7D%3Fwmode%3Dopaque%26showinfo %3D0%26autohide%3D1%26rel%3D0%26iv_load_policy%3D3%26enablejsapi%3D1
謝謝。
像魅力一樣工作。很容易在我的ng-repeat中實現(它有多種來源)。謝謝。 –
快樂幫助你! –