Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Order by not working in angularjs

Tags:

angularjs

Order by is not working for angularjs

<div class="friendprofile" ng-repeat="like in likePages| filter:likePages.pagename|orderBy:'likePages.pagename'">
    <img ng-src="{{like.pageimg}}">
    <span><a ng-href="#">{{like.pagename}}</a> </span>
</div>
like image 291
Ali Nouman Avatar asked Apr 08 '26 07:04

Ali Nouman


1 Answers

I think it's enough if you use

orderBy:'pagename'

Predicate is a property of an iterator. In your case it would be ordered by like['pagename']

Example: http://plnkr.co/edit/2bXWUadA2Lb8zhAXnnlp?p=preview

A predicate to be used by the comparator to determine the order of elements.

Can be one of:

function: Getter function. The result of this function will be sorted using the <, =, > operator.

string: An Angular expression which evaluates to an object to order by, such as 'name' to sort by a property called 'name'. Optionally prefixed with + or - to control ascending or descending sort order (for example, +name or -name).

Array: An array of function or string predicates. The first predicate in the array is used for sorting, but when two items are equivalent, the next predicate is used.

Source: https://docs.angularjs.org/api/ng/filter/orderBy

like image 121
akn Avatar answered Apr 11 '26 17:04

akn