Hello Aimery, how are you?
So to make a group without an index to make the filter, eg we will group by category (dogs, cats, horses) I made an example of code to use the way you quoted above:
myApp.controller('MainController', function($scope) {
$scope.values = [1,2,3,4,5,6,7,8,9,10];
$scope.grouped = [];
var i,t, j = $scope.values.length, chunk = 4;
for ( i = 0; i < j; i+=chunk ) {
$scope.grouped.push($scope.values.slice(i,i+chunk));
}
});
And can display as follows:
<body ng-app="myApp" ng-controller="MainController">
<div class="group">
<span ng-repeat="(key,value) in grouped">
<div>
<span ng-repeat="(key,each) in value">
{{ each }}
</span>
</div>
</span>
</div>
</body>
But I suggest you return a server object already with the categories to which they belong, for example:
$scope.animals = [
{name: 'Mia', category: 'cat'},
{name: 'Bugg', category: 'dog'},
{name: 'Kit', category: 'dog'},
{name: 'Kie', category: 'cat'},
{name: 'Mon', category: 'dog'}
];
With this, you can use an angular filter called groupBy, example:
<span ng-repeat="(key, value) in animals | groupBy: 'category'">
Category: {{ key }}
<li ng-repeat="animal in value">
</li>
</span>