AngularJs with iframe

走远了吗. 提交于 2019-12-20 02:42:10

问题


Why this jsfiddle is not working? I am not able to get value of videoId. If I remove ngRoute from module then it is working fine.


回答1:


You need to use ng-src like this:

<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>

and

var app = angular.module('my-app', []);
app.controller('AppController', function ($scope, $sce) {  
    $scope.videoID = $sce.trustAsResourceUrl('http://www.youtube.com/embed/C0DPdy98e4c');
});

See this documentation.



来源:https://stackoverflow.com/questions/19312045/angularjs-with-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!