0

I have an ng-repeat going, wherein:

<a ng-repeat="contact in contacts | orderBy:'name'">
{{contact.name}}
</a>

I have tried predicates: name, -name, name.substr(0, 3)

The contacts 'name' property is like "John Smith", "Betty Ford", "Hawkeye Pierce", etc.

The ng-repeat works, but the orderBy does not.

Is there a reason that my strings might not be sorting successfully?

2 Answers 2

1

1 : The orderBy only works with Arrays -- See http://docs.angularjs.org/api/ng.filter:orderBy

source : Angular - Can't make ng-repeat orderBy work

What is your 'contacts' ?

2 : try

<div ng-repeat="contact in contacts | orderBy:'name'">
<a>{{contact.name}}</a>
</div>
Sign up to request clarification or add additional context in comments.

Comments

0

Here is the working link for your case

Hope it helps for you

'http://plnkr.co/edit/EhV5RHszZns5qTHM8qBu?p=preview'

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.