我正在使用bootstrap multiselect select和angular ng-options来加载选项。
<select on-change-evt="#view-user"
ng-model="userCtrl.columnAllowed"
ng-options="item.displayName for item in userCtrl.userGridColumns track by item.id"
disable="item"
class="form-control btn btn-sm"
class="input-small" enable-filter="true" placeholder="Search column"
multiple="multiple" selected-text="Columns" number-displayed="2">
</select>
我需要选择一些最小选项作为默认选项,也必须禁用。
我试过ng-options="item.displayName disable when item.disabled == true for item in userCtrl.userGridColumns track by item.id"
但这并没有像预期的那样奏效。
答案 0 :(得分:1)
**
**
var app = angular.module('app', [ ]);
app.controller('MainCtrl', function($scope) {
$scope.cars = [{id:1, name: 'Audi', isDisabled: false}, {id:2, name: 'BMW', isDisabled: true}, {id:3, name: 'Honda', isDisabled: true}, {id:4, name: 'Mercedes-Benz', isDisabled: false}];
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="app" ng-controller="MainCtrl">
<div class="form-group">
<label>Select Multiple Specific options</label>
<select multiple="" class="form-control" >
<option ng-repeat="item in cars" ng-disabled="{{item.isDisabled}}">{{item.name}}</option>
</select>
</div>
</body>