Using Angular ng-repeat, I am trying to create a carousel with 3 <div> in each <li> . I can easily create it with 1 div per slide, but I canβt get 3. Using js, I would usually use the module (%) to find out if the index is divisible by 3, and then open / close li there.
Can this be done with Angular?
This is what I have (1 element per slide):
<ul carousel class="carousel"> <li class="slide" ng-repeat="item in item.list.items" ng-init="itemIndex = $index"> <div class="item">{{item}}</div> </li> </ul>
This is what I am trying to achieve (3 elements per slide):
<ul class="carousel"> <li class="slide"> <div class="item">Item 1</div> <div class="item">Item 2</div> <div class="item">Item 3</div> </li> <li class="slide"> <div class="item">Item 4</div> <div class="item">Item 5</div> <div class="item">Item 6</div> </li> </ul>
Edit
This question has been marked as a duplicate of byherwood. The question is very clearly asked about the use of the module in ng-if, not the controllers. The proposed duplicate is close, but Betty St answers the exact question below, with sample code and a link. Thanks Betty!
source share