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>

2 Answers 2

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

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

3 Comments

if transforming a database is not an option?
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 stackoverflow.com/questions/1069666/…
@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
0

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

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.