Can anyone help me in parsing below JSON Request using ng-repeat
I want to know how to use ng-repeat in HTML to get the description of the troubles in JSON
Using below code I am getting whole Object of trobles
posts.json
{
"persons": [
{
"properties": {
"label": "checked",
"type": "young"
},
"personType": "average",
"troubles": [],
"externalResourceLinks": []
},
{
"properties": {
"label": "checked",
"type": "aged"
},
"personType": "bad",
"troubles": [
{
"name": "Rocky",
"description": "Health problem",
"criticality": false,
"date": "2016-08-07T08:43:28+0000",
"longDate": 1470559408519
}
]
}
]
}
in HTML I am using
<tr>
<td class="features" ng-repeat="list in person">{{list.persontype}}</td>
</tr>
<tr>
<td class="features" ng-repeat="list in person">{{list.troubles}}</td>
</tr>
Angular Function
var app = angular.module('myApp', ["ngTable"]);
app.controller('PostsCtrlAjax', ['$scope', '$http', function($scope, $http) {
$http({
method: 'POST',
url: 'scripts/posts.json'
}).success(function(data) {
$scope.post = data;
persons = data['persons'];
$scope.person = persons;
})
}
]);