如何使用angularjs中的ng-repeat来迭代json数据
{
“CSS Corp”:{
"COE":{"win_loss":[6,4]},
"YNOS":{"win_loss":[5,5]},
"ESTEE":{"win_loss":[10,0]},
"ELC":{"win_loss":[8,2]}
},
“SSSPL”:{
"PEG":{"win_loss":[0,10]},
"ARUBA":{"win_loss":[2,8]},
"SALES":{"win_loss":[1,9]},
"MARKETING":{"win_loss":[7,3]}
},
}
答案 0 :(得分:0)
你的问题很广泛。首先,您必须将这些JSON数据附加到控制器的范围,并通过变量myData
将其公开给模板。假设您知道如何做到这一点,ng-repeat
的使用变得非常简单(添加更多列或行以适合您的数据集):
<table>
<thead>
<tr><th>Header 1</th></tr>
</thead>
<tbody>
<tr ng-repeat="item in myData">
<td>{{ item }}</td>
</tr>
</tbody>
</table>
答案 1 :(得分:0)
使用Vuejs browser extension without using 'unsafe-eval' in CSP
语法:<tr ng-repeat="value in container">
答案 2 :(得分:0)
假设您的JS中有一个JSON对象数组,如下所示,
var arrayObject = [
"CSS Corp":{
"COE":{"win_loss":[6,4]},
"YNOS":{"win_loss":[5,5]},
"ESTEE":{"win_loss":[10,0]},
"ELC":{"win_loss":[8,2]}
},
"SSSPL":{
"PEG":{"win_loss":[0,10]},
"ARUBA":{"win_loss":[2,8]},
"SALES":{"win_loss":[1,9]},
"MARKETING":{"win_loss":[7,3]}
}
];
然后您的视图应按以下方式迭代,
<div ng-repeat="company in arrayObject">
{{company}} // use whatever you want to print
</div>