Sunday, 8 May 2016

JSON data filter using javascript filter method

<!DOCTYPE html>
<html>
<body>

<div ng-app="myApp" ng-controller="customersCtrl"> 

<table>
<tr><th>Company Name</th><th>Date</th></tr>
  <tr ng-repeat="x in MyData">
    <td>{{ x.country }}</td>
    <td>{{ x.date }}</td>
  </tr>
</table>

</div>

<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
alert(JSON.stringify(response.data.response.data));
$scope.MyData = response.data.response.data.worldindiceslist.worldindices.filter(function(item){
return (item.indexid==20 || item.indexid==19 || item.indexid==15)
});//response.data.response.data.worldindiceslist.worldindices;
});
});
</script>

</body>
</html>

No comments:

Post a Comment