Is it possible to manipulate and sort multiple column in angularjs filter orderBy
?
JS
var myApp = angular.module('myApp', []);
function MyCtrl($scope, $filter) {
var r = [
{'group':1,'sub':1, 'date': '11/4/2014 2:01 PM'},
{'group':2,'sub':10, 'date': '11/4/2014 4:36 PM'},
{'group':1,'sub':2, 'date': '11/4/2014 8:59 AM'},
{'group':1,'sub':20, 'date': '4/14/2015 5:54 PM'},
{'group':2,'sub':1, 'date': '11/3/2014 9:09 PM'},
{'group':2,'sub':11, 'date': '9/4/2014 2:48 PM'}
];
$scope.mcards = $filter('orderBy')(r, [function(a){
return -new Date(a.date).getTime();
//manipulate the string and then sort it by ascending or descending order.
}]);
}
It is not working as expected whereas when I try it in the following way it works great,
$scope.mcards = $filter('orderBy')(r, ['group', function(a){
return -a.sub;
}]);
What is the problem here, am I missing something?