3

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>

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.