Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(orderBy): support sorting by value #5847

Closed
wants to merge 2 commits into from

Conversation

marshall007
Copy link

Fixes issue #4579, adding support for:

<p ng-repeat="item in items | orderBy">{{item}}</p>
<p ng-repeat="item in items | orderBy:'+'">{{item}}</p>
<p ng-repeat="item in items | orderBy:'-'">{{item}}</p>

It seems unnecessary and redundant in this particular scenario to support the reverseOrder parameter and taking sortPredicate as an array, so they are ignored (i.e. the following):

<p ng-repeat="item in items | orderBy:'+':false">{{item}}</p>
<p ng-repeat="item in items | orderBy:['+']">{{item}}</p>

@mary-poppins
Copy link

I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS.

Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match.

If you signed the CLA as a corporation, please let us know the company's name.

Thanks a bunch!

PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR.
PS2: If you are a Googler, please sign the CLA as well to simplify the CLA verification process.

@marshall007
Copy link
Author

CLA signed

@mary-poppins
Copy link

CLA signature verified! Thank you!

Someone from the team will now triage your PR and it will be processed based on the determined priority (doc updates and fixes with tests are prioritized over other changes).

@Narretz Narretz added this to the 1.3.0 milestone Jul 21, 2014
@marshall007
Copy link
Author

@ilanbiala FYI, there's a workaround for this is in the mean time:

<p ng-repeat="item in items | orderBy:'toString()'">{{item}}</p>

@ilanbiala
Copy link

Doesn't seem to work for me, can you provide a fiddle or a pen? I also tried :true and :false for order.

@marshall007
Copy link
Author

Sure, here's a fiddle.

@ilanbiala
Copy link

@marshall007 That only works for strings though, I just want to reverse an array and not have to do things like $scope.$watch and $scope.$observe and all that if Angular can do it for me. I hope this will get merged into 1.3.0-beta18 so i can test it out.

@marshall007
Copy link
Author

@ilanbiala This PR won't help you then, but it sounds like you could just use a filter. Here's another fiddle.

@ilanbiala
Copy link

Thanks!

@IgorMinar IgorMinar self-assigned this Oct 1, 2014
@IgorMinar IgorMinar modified the milestones: 1.3.0-rc.5, 1.3.0 Oct 1, 2014
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request Oct 2, 2014
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request Oct 2, 2014
@petebacondarwin
Copy link
Contributor

@marshall007 thanks for providing this patch but it can be done more consistently without having to ignore the various corner cases in a slightly different way. See #9403

petebacondarwin added a commit that referenced this pull request Oct 3, 2014
@marshall007
Copy link
Author

@petebacondarwin no problem, glad to see this finally resolved!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants