如果我想用角度J调用iframe链接,我会这样做:
HTML中的
<iframe width="560" height="315" ng-src="{{customUrl}}" frameborder="0" allowfullscreen></iframe>
在剧本中
$scope.customUrl = $sce.trustAsResourceUrl('https://www.youtube.com/embed/ie06-rsfgio');
但如果我想用几个iframe进行ng-repeat呢?
我可以制作这样的东西(显然不是这样)吗?
$scope.videoList = [video: $scope.customUrl = $sce.trustAsResourceUrl('https://www.youtube.com/embed/ie06-rsfgio'),
video: $scope.customUrl = $sce.trustAsResourceUrl('https://www.youtube.com/embed/ie06-rsfgio'),
video: $scope.customUrl = $sce.trustAsResourceUrl('https://www.youtube.com/embed/ie06-rsfgio')
]
答案 0 :(得分:0)
试试这个:做得好!! http://plnkr.co/edit/zf2YDyesNZXWwMrygNG1?p=preview
HTML:
<div ng-repeat = "src in sources track by $index">
<iframe width="560" height="315" ng-src="{{getTrust(src)}}" frameborder="0" allowfullscreen></iframe>
</div>
<强> JS:强>
$scope.sources = ['https://www.youtube.com/embed/ie06-rsfgio',
'https://www.youtube.com/embed/ie06-rsfgio',
];
$scope.getTrust = function(src){
return $sce.trustAsResourceUrl(src);
};