This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Add group by support to ngRepeat #4777
Open
Description
It would be nice if ngRepeat supported simple grouping similar to the select directive's option groups. For example:
<div ng-controller="MyCntrl">
<div ng-repeat="(shade, shadeColors) in colors group by c.shade">
<div>
Shade: {{shade}}
<div ng-repeat="color in shadeColors">
Color: {{color.name}}
</div>
</div>
</div>
</div>
function MyCntrl($scope) {
$scope.colors = [
{name:'black', shade:'dark'},
{name:'white', shade:'light'},
{name:'red', shade:'dark'},
{name:'blue', shade:'dark'},
{name:'yellow', shade:'light'}
];
}
Would produce the following:
<div>
<div>
<div>
Shade: dark
<div>
Color: black
</div>
<div>
Color: red
</div>
<div>
Color: blue
</div>
</div>
<div>
Shade: light
<div>
Color: white
</div>
<div>
Color: yellow
</div>
</div>
</div>
</div>