javascript - Sorting the date in JSON object angular JS -
i making angular application json object response. in response array have date element "lastupdatedby" want sort data through angular sort (orderby) latest updated data in bottom.
for comparison taking sysdate server in same json object "sysdate".
please provide me solution. don't know how give expression in orderby filter.
there's decent example of using orderby here:
angularjs orderby documentation
you should able this:
<tr ng-repeat="friend in friends | orderby:'lastupdatedby'"> <td>{{friend.name}}</td> <td>{{friend.phone}}</td> <td>{{friend.lastupdatedby}}</td> </tr>
perhaps it'd if showed orderby
have tried, isn't working...?
update
you can use orderby
if wanted sort data in angularjs controller, using this:
$scope.sortedarray = $filter('orderby')($scope.unsortedarray, 'lastupdatedby', true);
and you'd able most-recently updated item using:
$scope.sortedarray[0]
Comments
Post a Comment