如何重复这种json数据?我想分开回应游戏和统计数据。
{
"game": [
{
"home": "Home Team",
"away": "Away Team",
"date": "2015-01-13",
"result": "2-0"
}
],
"stats": [
{
"event": "Goal",
"time": 27,
"player": "Player One"
},
{
"event": "Yellow Card",
"time": 52,
"player": "Player Two",
}
]
}
提前谢谢!
答案 0 :(得分:2)
您只需要在每个对象中输入ng-repeat数据。让我们说你发布的JSON存储在$ scope.data中。要显示游戏信息,只需像这样给出重复游戏数组:
<div ng-repeat="g in data.game">
Home: {{g.home}}<br>
Away: {{g.away}}<br>
Date: {{g.date}}<br>
Result: {{g.result}}
</div>
使用统计信息执行相同的操作,然后显示每个数组中的信息。