0

All working but the orderBy not sorting items by order (value.points is a number)

<a class="item" ng-show="showResults" ng-repeat="(key, value) in event.tournaments | orderBy:'value.points'">
  <h3>{{key}} {{value.imitation}}</h3>
  <span class="badge badge-assertive">{{value.points}}</span>
</a>
n00b43677
  • 187
  • 2
  • 16

2 Answers2

1

From the documentation , orderBy orders only arrays. The (key, value) sintax works on objects. Maybe transform your dictionary in an array will do the trick

Slumber86
  • 673
  • 6
  • 8
  • if transforming a database is not an option? – n00b43677 Dec 06 '14 at 18:09
  • you must not trasform the database, only the intermediate object providede to front-end, after the service returns. Sorting object in javascript is not possible. Look here http://stackoverflow.com/questions/1069666/sorting-javascript-object-by-property-value – Slumber86 Dec 06 '14 at 18:18
  • 1
    @n00b43677 you don't have to transform database, only the api delivering the data. Angular works best with arrays of objects rather than simple arrays. Data can always be mapped from one structure to another in the client also – charlietfl Dec 06 '14 at 18:29
0

Shouldn't it be orderBy:value.points instead of orderBy:'value.points'?

luser
  • 11
  • 1