Can't load URL into iframe with angularJS Can't load URL into iframe with angularJS angularjs angularjs

Can't load URL into iframe with angularJS


In the controller you should use:

   $scope.myLink =  $sce.trustAsResourceUrl(myUrl)


It works for me : you can write this in js code as a function

$scope.trustSrc = function(src) {  return $sce.trustAsResourceUrl(src);}$scope.iframe = {src:"http://www.youtube.com/embed/Lx7ycjC8qjE"};

and use it in your view :

 <iframe ng-src="{{trustSrc(iframe.src)}}"></iframe>

or you can write it as a filter like :

.filter('trusted', function($sce){return function(url) {    return $sce.trustAsResourceUrl(url);};

})

and use it in view :

 <iframe ng-src="{{iframe.src | trusted}}"></iframe>