bootstrap multiselect下拉选项禁用

时间:2015-12-31 09:33:22

标签: angularjs twitter-bootstrap

我正在使用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" 但这并没有像预期的那样奏效。

1 个答案:

答案 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>