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?

GeneralBear
  • 1,011
  • 3
  • 11
  • 35

2 Answers2

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>
Community
  • 1
  • 1
0

Here is the working link for your case

Hope it helps for you

'http://plnkr.co/edit/EhV5RHszZns5qTHM8qBu?p=preview'
Arun AK
  • 4,353
  • 2
  • 23
  • 46