Tuesday, 19 April 2016

oredr by filter in angular:

This filter used to order elements in ascending / descending.

$scope.lists = [{name:'sai',company: 'CTS'},{name:'kiran',company: 'cognizant'},{name:'sai kiran',company: 'cognizant'},{name:'sai krishna',company: 'we'}]

Task1: ascending order

<ul>
<li ng-repeat="a in lists | filter:search:strict | orderBy : 'name'">[[a.name]]</li>
</ul>

Task2: descending order

by default order by ascending, to order  in descending use '-' symbol before attribute

<ul>
<li ng-repeat="a in lielementssts | filter:search:strict | orderBy : '-name'">[[a.name]]</li>
</ul>

No comments:

Post a Comment