Reputation: 1450
Following on from a previous question on this topic (orderBy multiple fields in Angular), I'm wondering if it is possible to achieve this. Essentially, I want to orderBy multiple fields, but give priority to one of the fields if their value isn't null.
I'm using orderBy like so:
orderBy:['-sub','group']
From what I understand, the first item in the list of fields is given priority, but they are appearing at the bottom of the list.
Upvotes: 0
Views: 1531
Reputation: 136124
Then you should do something like this orderBy:['!-sub','group']"
Markup
<div class="test" ng-controller="Ctrl">
<div ng-repeat="division in divisions | orderBy:['!-sub','group']">
{{division.group}}-{{division.sub}}
</div>
</div>
Upvotes: 2