JSON数据:
{
"title": "House of Cards",
"poster": "img/hoc1.jpg",
"imdbID": "tt1856010",
"trailer": "NTzycsqxYJ0"
},
{
"title": "Master of None",
"poster": "img/mon1",
"imdbID": "tt4635276",
"trailer": "6bFvb3WKISk"
}
我必须抓取"预告片":" 6bFvb3WKISk"从JSON链接到我的iframe链接
<iframe src={`https://www.youtube-nocookie.com/embed/{{}}?rel=0&controls=0&showinfo=0`}
frameBorder="0"
allowFullScreen
title={{}} />
使用ng-repeat
指令
请帮帮我
答案 0 :(得分:0)
使用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';
}
希望它有帮助!