Since the filter is orderBy , you can use this. Your ng-repear probably looks something like this:
ng-repeat="item in items | orderBy: orderByDate"
and then on the controller you define the orderByDate function:
$scope.orderByDate = function(item) { var parts = item.dateString.split('-'); var date = new Date(parseInt(parts[2], parseInt(parts[1]), parseInt(parts[0])); return date; };
The implementation of the function is up to you. I choose to create a Date from a string. The object that you return from the orderByDate function is then used for order using the <, =,> operators.
EDIT: solution for :reverse
Since :reverse cannot be used with the function passed as a parameter, you can implement your custom function to return the opposite value. In this case, using Date impossible, I would then build a number and return it with a minus:
$scope.orderByDate = function(item) { var parts = item.dateString.split('-'); var number = parseInt(parts[2] + parts[1] + parts[0]); return -number; };
source share