2016-05-19 3 views
0

Я бегу в Error: $interpolate:interr Interpolation Error с динамическим размещением видео в формате iframe в iframe.Как динамически добавлять iframe src с помощью Angular

HTML

<div class="embed-responsive embed-responsive-16by9"> 
    <iframe class="embed-responsive-item" src="{{youtubeVideo}}" allowfullscreen></iframe> 
</div> 

Javascript/Угловая

$http({ 
    method: 'GET', 
    url: getTankVideos(query) 
}).then(function successCallback(response) { 
    console.debug('response'); 
    console.debug(response); 

    $scope.youtube = response; 
    console.log('Youtube'); 
    console.log($scope.youtube); 

    console.log('Video Url'); 
    $scope.youtubeVideo = 'https://www.youtube.com/watch?v=' + $scope.youtube.data.items[0].id.videoId; 
    console.log($scope.youtubeVideo); 

}, function errorCallback(response) { 
    // called asynchronously if an error occurs 
    // or server returns response with an error status. 
}); 

Мои отлаживать заявления дают мне действительные значения

response 
script.js:129 Object {data: Object, status: 200, config: Object, statusText: ""} 
script.js:131 Youtube 
script.js:132 Object {data: Object, status: 200, config: Object, statusText: ""} 
script.js:134 Video Url 
script.js:135 https://www.youtube.com/watch?v=BRtj_TSOHjw 

ответ

0

Для безопасности, Вам необходимо впрыскивать $sce службу в контроллере и trustAsResourceUrl url там.

$scope.youtubeVideo = $sce.trustAsResourceUrl('https://www.youtube.com/watch?v=' + $scope.youtube.data.items[0].id.videoId); 
+0

Спасибо, это определенно было – Programatic