0

Total 20 Images, I have to show 9 items in each slider so total 3 slider.

I tried this following link

Four items in bootstrap carousel Ng repeat?

<div class='greybg' ng-repeat="comment in location.comments"> 
          <div class="row">
    <div id="myCarousel{{location.comments[0]._id}}" class="carousel slide" data-ride="carousel">
    <div class="carousel-inner  multiple_pictures" >
    <div class="item" ng-class="{active:!$index}">
    <div class="row" >
    <div class="col-sm-4"  ng-repeat="images in comment.images.slice(0,9)">
    <img ng-src={{images.path}} alt="First slide"> <div class="gplabel">{{$index+1}}</div>
    </div>
    </div>  
    </div>
    <div class="item">
    <div class="row">
    <div class="col-sm-4"  ng-repeat="images in comment.images.slice(9,18)">
    <img ng-src={{images.path}} alt="First slide"> <div class="gplabel">{{$index+1+9}}</div>
    </div>
    </div>
    </div>
    <div class="item">
    <div class="row">
    <div class="col-sm-4"  ng-repeat="images in comment.images.slice(18,27)">
    <img ng-src={{images.path}} alt="First slide"> <div class="gplabel">{{$index+1+18}}</div>
    </div>
    </div>
    </div>
    <a ng-if="comment.images.length>1" class="left carousel-control" href="#myCarousel{{location.comments[0]._id}}" role="button"
    data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
    </a>
    <a ng-if="comment.images.length>1" class="right carousel-control" href="#myCarousel{{location.comments[0]._id}}" role="button"
    data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
    </a>
    </div>
    </div></div></div>

But the image count will be dynamical so If am having 50 image means 6 times I have to write. How do i do this dynamically based upon image count.

Vishnu
  • 745
  • 12
  • 32
  • You slice the `comment.images` array in your controller so you'll get an array of arrays, then use two nested `ng-repeat` loops. –  Sep 07 '18 at 09:29
  • Ok I will try this solution – Vishnu Sep 07 '18 at 09:31
  • Am getting that comment.images from the ejs file only then how can i able to splice? Could you pls show me some example – Vishnu Sep 07 '18 at 10:45

0 Answers0