当所选列表为空矩形时禁用ui-select

时间:2016-06-05 08:41:58

标签: angularjs ui-select

如果没有要选择的项目

,如何禁用ui-select- multi select的选择框
<ui-select
                                multiple  theme="bootstrap"
                                ng-model="categories.selected"
                                on-select="selectCategory($item,$model)">
                            <ui-select-match placeholder="Select Item...">{{$item.name}}</ui-select-match>
                            <ui-select-choices
                                    repeat="category in categories.categories track by category.id">
                                {{category.name}}
                            </ui-select-choices>
                        </ui-select>

2 个答案:

答案 0 :(得分:0)

ui-select指令提供ng-disabled属性。

示例:

<ui-select
                                multiple  theme="bootstrap"
                                ng-model="categories.selected"
                                on-select="selectCategory($item,$model)"
                                ng-disabled="categories.categories.length === 0">
                            <ui-select-match placeholder="Select Item...">{{$item.name}}</ui-select-match>
                            <ui-select-choices
                                    repeat="category in categories.categories track by category.id">
                                {{category.name}}
                            </ui-select-choices>
                        </ui-select>

答案 1 :(得分:0)

您始终可以使用ng-disabled禁用Angular提供的任何组件。因此,您也可以将ng-disabledui-select一起使用。

<ui-select
                                multiple  theme="bootstrap"
                                ng-model="categories.selected"
                                ng-disabled="categories.selected.length === 0"
                                on-select="selectCategory($item,$model)">
                            <ui-select-match placeholder="Select Item...">{{$item.name}}</ui-select-match>
                            <ui-select-choices
                                    repeat="category in categories.categories track by category.id">
                                {{category.name}}
                            </ui-select-choices>
                        </ui-select>