angularjs - how to get the min and max value from json in angular js -


i want maximum , minimum value json in angular js json:

{  "data":[          {          "name": "ranjith",          "age": 22         },         {          "name": "rahul",          "age": 20         },         {          "name": "jinesh",          "age": 25         },         {          "name": "vishnu",          "age": 24         }         ]  } 

and controller:-

var app = angular.module('myapp', ['']); app.controller('myctrl', function($scope, data) {  $scope.data = data.data; $scope.min=""; $scope.max="";  }; }); 

i want minimum , maximum value array , store in variables min , max

you can use

$scope.min = math.min.apply(math,$scope.data.map(function(item){return item.age;}));  $scope.max = math.max.apply(math,$scope.data.map(function(item){return item.age;})); 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -