Angularjs ngrepeat递增

时间:2013-09-20 12:13:03

标签: angularjs angularjs-ng-repeat

我每次在这里增加3比1而不是1增加营地?

<div class="row" ng-repeat="camp in camps">
                <div class="col-lg-3">
            <img src={{camp.img}} alt="" height="200pt" width="250pt"/></div>
            <div class="col-lg-5 col-lg-offset-1">{{camp.email}}<br/>
            <span>{{camp.campname}}</span><br/>
            {{camp.about}}<br/>
            {{camp.tgtamt}}<br/>
            {{camp.enddate}}<br/><br/>
            <button id="view" class="btn btn-default" value1='{{camp.campname}}' value2='{{camp.email}}'>View</button>
            </div></div>
            <hr/>
        </div>

1 个答案:

答案 0 :(得分:0)

您可以尝试将$indexng-show一起使用。类似的东西:

<强> HTML

<div ng-controller = "myCtrl1"> 
 <div class="row" ng-repeat="camp in camps">
 <div ng-show="$index % 3 == 0"> <pre>{{camp.name}}</pre></div>          

    </div>
</div>

<强>控制器

var myApp = angular.module('myModule', []);

myApp.controller('myCtrl1', ['$scope', function($scope) {
$scope.camps=
    [{name:"name_1"},{name:"name_2"},{name:"name_3"},{name:"name_4"},{name:"name_5"},
     {name:"name_6"},{name:"name_7"},{name:"name_8"},{name:"name_9"},{name:"name_10"}];    

}]);

输出:

name_1
name_4
name_7
name_10

参见 Fiddle