2013-12-11 44 views

回答

5

在控制器添加:

$scope.isDisabled = false; // change to true to disable the multiselect 

然後,視圖應該是(看禁用屬性):

<multiselect class="input-xlarge" multiple="true" 
    ng-model="selectedCar" 
    options="c.name for c in cars" 
    change="selected()" disabled="isDisabled"></multiselect> 

最後,添加適當的邏輯來在您的控制器中設置$ scope.isDisabled。

+0

嗨感謝您的建議, 但我試過上面的解決方案,但不會工作對我來說可能是我把控制器不適當的地方。 你可以告訴我在哪裏添加控制器在波紋管代碼中: >>>>>>>>>>>>>>> var app = angular.module('plunker',['ui.multiselect' ]); app.controller('MainCtrl',function($ scope){ $ scope.name ='World'; $ scope.cars = [{id:1,name:'Audi'},{id:2,名稱:'BMW'},{id:1,name:'Honda'}]; $ scope.selectedCar = []; $ scope.fruits = [{id:1,name:'Apple'},{ id:2,name:'Orange'},{id:3,name:'Banana'}]; $ scope.selectedFruit = null; }); – Pawan

+0

否則可能會有幫助,如果你可以編輯成plnkr – Pawan

+0

請重新閱讀我的答案。我只是分叉你的plnkr,包括我的修改:http://plnkr.co/edit/oWPIPH5XVPI7UNZsB2Gz?p=preview – alle