1. 程式人生 > >angularjs ui-select 如果select的內容為空 則禁止點選

angularjs ui-select 如果select的內容為空 則禁止點選

I usually use ng-disable on myArray.length to get a 0 or !0 and use it as false and true. Always worked for me.

<selectng-model="model.a"ng-options="value for a in array"ng-disabled="!array.length"></select>

What about in your exemple :

<ui-selectid="Models"ng-model="request.model"ng-disabled
="!request.make.length"><ui-select-matchplaceholder="Enter a Model…">{{$select.selected.name}}</ui-select-match><ui-select-choicesrepeat="choice in request.make.models | filter: $select.search"><divng-bind-html="choice.name | highlight: $select.search"></div></ui-select-choices>

In your current code request.make would return [] and not 'false' ... if I understood well.