在bootstrap行上应用ng-repeat

时间:2015-07-24 11:20:24

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

我试图将ng-repeat应用于标有类"公司"的cols。我不能这样做,因为" row"打破了两者之间的顺序。

我需要展示超过1000多家这样的公司。我该怎么办?

    <div class="row">
        <div class="col-sm-6 col-xs-12 company">
            <small>Users</small>
            <small>Followers</small>
        </div>
        <div class="col-sm-6 col-xs-12 company">
            <small>Users</small>
            <small>Followers</small>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-6 col-xs-12 company">
            <small>users</small>
            <small>Followers</small>
        </div>
        <div class="col-sm-6 col-xs-12 company">
            <small>users</small>
            <small>Followers</small>
        </div>
    </div>

2 个答案:

答案 0 :(得分:0)

尝试

<div class="row" ng-repeat="i in getNumber(1000)">
        <div class="col-sm-6 col-xs-12 company">
            <small>users</small>
            <small>Followers</small>
        </div>
        <div class="col-sm-6 col-xs-12 company">
            <small>users</small>
            <small>Followers</small>
        </div>
 </div>

在控制器中

$scope.getNumber = function(num) {
    return new Array(num);   
 }

答案 1 :(得分:0)

如果您尝试重复.company元素,则应在ng-repeat元素上应用.company

<div class="row">
    <div class="col-sm-6 col-xs-12 company" ng-repeat="i in getNumber(1000)">
        <small>users</small>
        <small>Followers</small>
        <small>...</small>
    </div>
</div>

如果您担心.col-sm-6没有包装到第3 +元素的下一行,则引导程序和浏览器可以将它们包装到下一行。请参阅JSFiddle - http://jsfiddle.net/s0x7v41p/1/