在带有ng-repeat的bootstrap套管中显示9个项目

时间:2018-09-07 09:27:20

标签: javascript jquery html angularjs bootstrap-carousel

总共20张图像,我必须在每个滑块中显示9个项目,因此总共需要3个滑块。

我尝试了以下链接

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>

但是图像计数将是动态的,因此如果拥有50张图像,则意味着我必须写6次。如何根据图片数量动态地做到这一点。

0 个答案:

没有答案