I have been trying to fetch a section of the response json data from an API call in my angular application.
I have tried various combinations but I am only able to fetch the last record and not both the records.
Here is my html
<div ng-controller="MyCtrl">
<li ng-repeat="x in textvalues">
{{ x.event.description }}
</li>
</div>
and the controller code
var myApp = angular.module('myApp', []);
function MyCtrl($scope, $http) {
$http.get('http://www.vizgr.org/historical-events/search.php?', {params: {format: 'json', query:'India', limit:'2'}}).then(function(response) {
$scope.textvalues = response.data;
console.log($scope.textvalues);
});
}
The response from the API call is as follows:
{
"result": {
"count": "2",
"event": {
"date": "-293",
"description": "When an invasion of",
"lang": "en",
"category1": "By place",
"category2": "Persia",
"granularity": "year"
},
"event": {
"date": "-250",
"description": "The Mauryan s",
"lang": "en",
"category1": "By place",
"category2": "India",
"granularity": "year"
}
}
}
And I am trying to print the event description in loop on the UI
Here is my fiddle - http://jsfiddle.net/nirajupadhyay/Jd2Hw/105/
I have tried various combination of the response data but unable to get to both the descriptions.
Kindly help.