Reputation: 388
How can I ng-repeat this kind of json data? I want to echo game and stats separataly.
{
"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",
}
]
}
Thank you in advance!
Upvotes: 2
Views: 162
Reputation: 653
You just have to feed ng-repeat the data inside each object. Let's say that the JSON you posted is stored in $scope.data. To get show the game information, just give ng-repeat the game array like so:
<div ng-repeat="g in data.game">
Home: {{g.home}}<br>
Away: {{g.away}}<br>
Date: {{g.date}}<br>
Result: {{g.result}}
</div>
Do the same thing with stats and you display the information from each array.
Upvotes: 2