3

I do have objects of the following form:

item = {key1: {count: x}} where x is an integer

I would like to sort my options in my template using count. I am using ng-options in the following way:

data-ng-options="key1 for (key1, sub_item) in item | orderBy: 'sub_item.count'"

Unfortunately, the sort isn't working. Any idea how I could achieve this ?

Scipion
  • 11,449
  • 19
  • 74
  • 139

1 Answers1

0

According to the docs you have to set the orderBy value in quotes:

orderBy: 'sub_item.count'
LarsBauer
  • 1,539
  • 18
  • 23
  • I did try to change it, but it is still not ordering unfortunately. Thanks though. – Scipion May 17 '15 at 13:07
  • 1
    It doesn't work because orderBy needs an array. You have an object. Convert it to an array and you'll be all set. – jme11 May 17 '15 at 14:11