AngularJS中的自定义排序功能

问题描述:

如何定制自定义函数?AngularJS中的自定义排序功能

我做了这个plunker,并注意到我一次得到一个元素,这阻止了我排序数组的元素。任何想法?

我看到这两个问题,但没有帮助: angularjs custom sort function in ng-repeatêAngularJS: Custom Sorting Function using OrderBy

你需要从你的功能,将针对其他值进行比较返回值。

例如,它看起来像你想在生日那天排序的plunkr。

你可能会喜欢这样一个功能做到这一点:

$scope.customSortFunc = function(person) { 
    return new Date(person.birthday); 
}; 

牢记不同的浏览器支持解析不同的日期格式,所以最好你会使用类似momentjs

Example Plunkr

+0

谢谢@JohnLedbetter。在我使用[sugar](http://sugarjs.com/dates)的情况下, – ThCC