2016-07-25 72 views
-1
<div class="row"> 
    <div class="col-xs-12"> 
    <button ng-repeat="item in items track by $index"> 
     {{item}} 
    </button> 
    </div> 
</div> 

我有3個項目,並希望把他們這樣NG重複多行使用引導

1 2 3 
4 5 6 

,所以我想有2行。但我的重複是項目本身。我如何解決上述情況?

回答

0

試試這個,

var app = angular.module('plunker', []); 
 

 
app.controller('MainCtrl', function($scope) { 
 
    $scope.items = [ 
 
    { 
 
    id: 1, 
 
    value: 'column1' 
 
    }, 
 
    { 
 
    id: 2, 
 
    value: 'column2' 
 
    }, 
 
{ 
 
    id: 3, 
 
    value: 'column3' 
 
    }, 
 
    { 
 
    id: 4, 
 
    value: 'column4' 
 
    }, 
 
    { 
 
    id: 5, 
 
    value: 'column5' 
 
    }, 
 
    { 
 
    id: 6, 
 
    value: 'column6' 
 
    }, 
 
{ 
 
    id: 7, 
 
    value: 'column7' 
 
    }, 
 
    { 
 
    id: 8, 
 
    value: 'column8' 
 
    }, 
 
]; 
 
});
<!DOCTYPE html> 
 
<html> 
 

 
    <head> 
 
    <meta charset="utf-8" /> 
 
    <title>AngularJS Plunker</title> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
 
    <link href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" rel="stylesheet" data-semver="4.0.0-alpha.2" data-require="[email protected]*" /> 
 
    <script src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js" data-semver="4.0.0-alpha.2" data-require="[email protected]*"></script> 
 
    <script>document.write('<base href="' + document.location + '" />');</script> 
 
    <link href="style.css" rel="stylesheet" /> 
 
    <script data-semver="1.4.9" src="https://code.angularjs.org/1.4.9/angular.js" data-require="[email protected]"></script> 
 
    
 
    <script src="app.js"></script> 
 
    </head> 
 

 
    <body ng-app="plunker" ng-controller="MainCtrl"> 
 
    <div ng-repeat="item in items"> 
 
     <div class="col-xs-4"> 
 
     {{item.value}} 
 
    </div> 
 
     
 
    </div> 
 
    </body> 
 

 
</html>

+1

所以ü變更後的標籤?但這樣做也是有道理的 –

0

在這裏你有一個小提琴,我在幾秒鐘內做出的...它應該沒有「行」類也行得通。

*{ 
 
    text-align: center; 
 
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/> 
 
<div class="row"> 
 
    <div class="col-xs-12"> 
 
     <!-- Here goes your ng-repeat --> 
 
     <div class="col-xs-4"> 
 
     1 
 
     </div> 
 
     <div class="col-xs-4"> 
 
     2 
 
     </div> 
 
     <div class="col-xs-4"> 
 
     3 
 
     </div> 
 
     <div class="col-xs-4"> 
 
     4 
 
     </div> 
 
     <div class="col-xs-4"> 
 
     5 
 
     </div> 
 
     <div class="col-xs-4"> 
 
     6 
 
     </div> 
 
     <!-- End of ng-repeat --> 
 
    </div> 
 
</div>