You can write your own sort getter. Instead of orderBy:'age', you can put a
function on the scope that does a better job of getting the search key.
Ex:
$scope.sorter = function(val) {return parseInt(val.age)}
ng-repeat="item in theList | orderBy:sorter"
e
On Thu Nov 27 2014 at 8:11:12 AM Leonard Modoran <[email protected]>
wrote:
> I have a big json object, that have all the key, values as strings so they
> are inside the quotes.
>
> ex. { "Name": "John Doe", "Age": "30"}
>
> The problems is if you have multiple fields like this, is that you make a
> sorting with orderBy on the ng-repeat, the default sorting is by name, and
> it's working the same also for numbers.
>
> so the order will be 1, 10, 11, 2, 20 ,25,3, 40 instead of 1, 2, 3, 10,
> 11, 20, 25,40
>
>
> How to convert it so will see it as a number, and this by not altering the
> json values.
>
>
> Thank you!
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.