json数据:
{
"title": "House of Cards",
"poster": "img/hoc1.jpg",
"imdbID": "tt1856010",
"trailer": "NTzycsqxYJ0"
},
{
"title": "Master of None",
"poster": "img/mon1",
"imdbID": "tt4635276",
"trailer": "6bFvb3WKISk"
}
我必须获取"预告片":"从json到我的iframe链接
的6bfvb3wkisk"链接<iframe src={`https://www.youtube-nocookie.com/embed/{{}}?rel=0&controls=0&showinfo=0`}
frameBorder="0"
allowFullScreen
title={{}} />
使用ng-repeat
指令
请帮助我
使用ng-src。
<div ng-repeat="d in data">
<iframe ng-src="setLink(d.trailer)" />
</div>
在控制器中
$scope.setLink = function(arg){
return 'https://www.youtube-nocookie.com/embed/'+arg+'?rel=0&controls=0&showinfo=0';
}
希望它有帮助!