我想找到一种方法,通过代码清除 ui-select 的选择。
例如我有以下代码
<ui-select ng-model="selectedCustomerCode" ng-if="CustomerIds.length>1" on-select="CustomerCodeFiltersOnSelectCallback($item, $model)" theme="bootstrap">
<ui-select-match class="ui-select-match" allow-clear="true" placeholder="Επιλογή κωδικού πελάτη...">{{$select.selected.CCode}}</ui-select-match>
<ui-select-choices class="ui-select-choices" repeat="customer in CustomerIds | propsFilter: {CCode: $select.search}">
<div ng-bind-html="customer.CCode | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
我想点击一个清除按钮并清除一些输入,包括 ui-select。 清除ui-select的代码是什么?
最佳答案
问题已解决。
我不知道为什么,但是在 ng-model 中只有 selectedCustomerCode
不能正常工作。
我将 selectedCustomerCode
分配为对象:
ng-model="selectedCustomer.selectedCustomerCode"
然后我能够像这样清除它:
selectedCustomer.selectedCustomerCode = ''
如果我有
ng-model="selectedCustomerCode"
然后将其重新分配给:
selectedCustomerCode = ''
不知何故不起作用。
关于angularjs - 如何以编程方式清除 ui-select?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41423987/