0
我总共有10个按钮,我怎么能移动到一个新行,每2个按钮:更改为新行每2个按钮
HTML:
<div ng-controller="SimpleArrayCtrl">
<div class="form-group">
<label ng-repeat="fruitName in fruits" class="checkbox-inline">
<input type="checkbox"
name="selectedFruits[]"
value = {{fruitName}}"
ng-checked="selection.indexOf(fruitName) > -1"
ng-click="toggleSelection(fruitName)"
> {{fruitName}}
</label>
</div>
</div>
JS:
(function (app) {
'use strict';
app.controller('SimpleArrayCtrl',
['$scope', function SimpleArrayCtrl($scope) {
// fruits
$scope.fruits = ['apple', 'banana', 'c', 'd','e','f','g','h','i','j'];
// selected fruits
$scope.selection = [];
// toggle selection for a given fruit by name
$scope.toggleSelection = function toggleSelection(fruitName) {
var idx = $scope.selection.indexOf(fruitName);
// is currently selected
if (idx > -1) {
$scope.selection.splice(idx, 1);
}
// is newly selected
else {
$scope.selection.push(fruitName);
}
};
}]);
})(angular.module('app', []));
https://jsbin.com/goqekewalu/edit?html,js,output
你或许可以这样做只是使用CSS,设置样式为'复选框,inline'到是50%宽? – haxxxton