1

在从 ui-select 中选择两项后禁用 ui-select-choices,除非用户删除了至少一项。此代码适用于多选。限制属性不起作用。因此,我使用 on-select 来提醒用户如果他们选择了超过 2 个项目。但要求是限制 2 并禁用选择。我们如何做到这一点?

 <ui-select multiple ng-model="cModel.selectedCountries" ng-disabled="isReadOnly" theme="bootstrap" on-select="someFunction($item, $model)">
                                <ui-select-match placeholder="Select ..." allow-clear="true">{{$item.name}}
                                </ui-select-match>
                                <ui-select-choices repeat="country.id as country in countryCodes | filter:$select.search">
                                    {{ country.name }}
                                </ui-select-choices>
                            </ui-select>
4

1 回答 1

1

这是你在找什么

<ui-select multiple limit="2" ng-model="cModel.selectedCountries" ng-disabled="isReadOnly" theme="bootstrap" on-select="someFunction($item, $model)">
                                <ui-select-match placeholder="Select ..." allow-clear="true">{{$item.name}}
                                </ui-select-match>
                                <ui-select-choices repeat="country.id as country in countryCodes | filter:$select.search">
                                    {{ country.name }}
                                </ui-select-choices>
                            </ui-select>
于 2016-03-24T02:29:41.643 回答