引导转盘Ng重复四项?

时间:2017-03-27 18:47:21

标签: javascript jquery angularjs twitter-bootstrap angularjs-ng-repeat

我试图在幻灯片中显示四个项目。但是我如何重复主行,因为它使用活动类作为活动幻灯片。这就是我的HTML外观。

<div class="carousel slide" id="myCarousel">
        <div class="carousel-inner">
            <div class="item active">
                <div class="row">
                    <div class="col-xs-3" ng-repeat="image in images"><a href="#"><img ng-src="{{image}}" class="img-responsive"></a></div>
                </div>
            </div>
        </div>
        <a class="left carousel-control" href="#myCarousel" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>
        <a class="right carousel-control" href="#myCarousel" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
    </div>

JSON的一个例子。

$scope.images = [
"http://placehold.it/500/e499e4/fff&amp;text=1",
"http://placehold.it/500/e499e4/fff&amp;text=2",
"http://placehold.it/500/e499e4/fff&amp;text=3",
"http://placehold.it/500/e499e4/fff&amp;text=4",
"http://placehold.it/500/e499e4/fff&amp;text=5",
"http://placehold.it/500/e499e4/fff&amp;text=6",
"http://placehold.it/500/e499e4/fff&amp;text=7",
]

1 个答案:

答案 0 :(得分:0)

你可以做的一种方法是将数组分成块......

<div class="item active">
    <div class="row">
        <div class="col-xs-3" ng-repeat="image in images.slice(0,4)"><a href="#"><img ng-src="{{image}}" class="img-responsive"></a></div>
    </div>
</div>
<div class="item">
    <div class="row">
        <div class="col-xs-3" ng-repeat="image in images.slice(5,9)"><a href="#"><img ng-src="{{image}}" class="img-responsive"></a></div>
    </div>
</div>

Demo