I am working with angularjs ng-repeat. I have this code:
angular.module('app', [])
.controller('MainCtrl', function($scope) {
var items = [1,2,3,4,5,6,7];
$scope.items = items;
});
I want to have html result like this:
<ul>
<li>
<a href="">1</a>
<a href="">2</a>
</li>
<li>
<a href="">3</a>
<a href="">4</a>
</li>
<li>
<a href="">5</a>
<a href="">6</a>
</li>
<li>
<a href="">7</a>
</li>
</ul>
The li element needs to be automatically generated as well. I have tried to use ng-repeat, but I am having difficulty with nested ng-repeat.
ng-repeat. It's very helpful for us to see what you've tried. It allows us to better understand the exact problems you're running into.$indexinside of ng-repeat to get the iterator offset. You could probably use that in combination with the mod%operator to build that HTML$indexis an option, I prefer keeping this kind of logic in the angular controller (javascript). I'd turn the array into an array of pairs first, thenng-repeaton that array of pairs.