Angularjs 从ui选择中选择两个项目后禁用ui选择选项,除非用户至少删除一个项目

Angularjs 从ui选择中选择两个项目后禁用ui选择选项,除非用户至少删除一个项目,angularjs,angular-ui,angular-ui-select,Angularjs,Angular Ui,Angular Ui Select,从ui选择中选择两个项目后禁用ui选择选项,除非用户至少删除一个项目。此代码适用于multiselect。限制属性不起作用。因此,我使用select来提醒用户如果他们选择了两个以上的项目。但要求是限制2并禁用选择。我们怎么做 <ui-select multiple ng-model="cModel.selectedCountries" ng-disabled="isReadOnly" theme="bootstrap" on-select="someFunction($item, $mo

从ui选择中选择两个项目后禁用ui选择选项,除非用户至少删除一个项目。此代码适用于multiselect。限制属性不起作用。因此,我使用select来提醒用户如果他们选择了两个以上的项目。但要求是限制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>

{{$item.name}
{{country.name}

这就是你要找的吗


{{$item.name}
{{country.name}

如果限制属性有效,我将是最快乐的人。但是,不,limit属性不起作用。是的,我只寻找该功能。由于limit不起作用,所以我尝试手动模拟该功能。