且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

外部资源不被AngularJs加载

更新时间:2023-10-25 23:32:58

这仅仅是为我工作的解决方案:

This is the only solution that worked for me:

var app = angular.module('plunker', ['ngSanitize']);

app.controller('MainCtrl', function($scope, $sce) {
  $scope.trustSrc = function(src) {
    return $sce.trustAsResourceUrl(src);
  }

  $scope.movie = {src:"http://www.***.com/embed/Lx7ycjC8qjE", title:"Egghead.io AngularJS Binding"};
});

然后在iframe:

Then in an iframe:

<iframe class="***-player" type="text/html" width="640" height="385" ng-src="{{trustSrc(movie.src)}}" allowfullscreen frameborder="0">

http://plnkr.co/edit/tYq22VjwB10WmytQO9Pb?p=$p$pview