I'm using Angular-Filter's groupBy filter.
Example from GitHub:
$scope.players = [
{name: 'Gene', team: 'alpha'},
{name: 'George', team: 'beta'},
{name: 'Steve', team: 'gamma'},
{name: 'Paula', team: 'beta'},
{name: 'Scruath', team: 'gamma'}
];
<ul>
<li ng-repeat="(key, value) in players | groupBy: 'team'">
Group name: {{ key }}
<ul>
<li ng-repeat="player in value">
player: {{ player.name }}
</li>
</ul>
</li>
</ul>
So, the example groups the players collection by team. Imagine there's an age property for every player object:
$scope.players = [
{name: 'Gene', team: 'alpha', age: 19},
{name: 'George', team: 'beta', age: 19},
{name: 'Steve', team: 'gamma', age: 23},
{name: 'Paula', team: 'beta', age: 23},
{name: 'Scruath', team: 'gamma', age: 23}
];
I want to group by team and age. How can I do that?
groupBy
would do what you need – Timbre