Common Questions (original) (raw)
- How to use orderBy with groupBy ?
- How to filter (key, value) with ng-repeat ?
- How can I inject specific filter to controller / service ?
- How can I extend or override existing filters ?
order groupBy result
Question: how to use orderBy with groupBy ?
See: issue #26
$scope.groups = [ { category: 'alpha', id: 2 }, { category: 'beta', id: 3 }, { category: 'gamma', id: 0 }, { category: 'alpha', id: 4 }, { category: 'beta', id: 5 }, { category: 'gamma', id: 1 } ]; // retrieves the min 'id' of a collection, used for the group ordering. //you can use lodash instead. e.g: _.min(arr, 'id') $scope.min = function(arr) { return $filter('min') ($filter('map')(arr, 'id')); }
- {{ group.$key }}
- {{ item }}