what i am trying to achieve: what i want to achieve is that to add an new row of ul after every 2 elements in my ng-repeat loop
for example
<ul class="col-sm-2">
<li><p>Automobile & Motorcycle</p></li>
<li><a href="#">Diagnostic Tools</a></li>
</ul>
<ul class="col-sm-2">
<li><p>Automobile & Motorcycle</p></li>
<li><a href="#">Diagnostic Tools</a></li>
</ul>
no how can i do this in ng-repea
t?
is there any possiblity using ng-repeat-start/end
i havent been able to try any thing in angular view as i am not able to make any logic sorry for that, but i can get this done with java script by
for (index=0,i=0,j=$scope.items.length; i<j; i+=chunk,index++) {
temparray [index]= $scope.items.slice(i,i+chunk);
}
$scope.items =temparray;
or
$scope.groupByTwo = function (array)
{
var newarray =[];
index=0;
for(a=0;a<array.length;a++){
if(a==0 || a%2==0){
newarray[index]=[];
newarray[index].push(array[a]);
}else{
newarray[index].push(array[a]);
}
if(a!=0)
index++;
}
return newarray;
}
$scope.items=$scope.groupByTwo($scope.items);
Question is their any angular way of doing this cleanly?