[英]AngularJS: ui-select once selected not able to remove selected option apart from change option
I am using ui-select for fetching data from server & populate it in drop down (search & select). 我正在使用ui-select从服务器获取数据并在下拉列表中填充(搜索和选择)。 I created a plunker for you.
我为你创造了一个plunker 。
<ui-select ng-model="country.selected" theme="selectize" ng-disabled="disabled" style="width: 300px;">
<ui-select-match placeholder="Select or search a country in the list...">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="country in countries | filter: $select.search">
<span ng-bind-html="country.name | highlight: $select.search"></span>
<small ng-bind-html="country.code | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
Once I selected any value from selector, I can change further. 一旦我从选择器中选择了任何值,我就可以进一步改变。 But not able to remove.
但是无法删除。 How can I do this?
我怎样才能做到这一点?
You should use an other theme like select2
to make this work. 您应该使用像
select2
这样的其他主题来完成这项工作。 I upgraded your PLUNKER to show how this could work. 我升级了你的PLUNKER以展示它是如何工作的。 Add
allow-clear="true"
into ui-select-match
and set theme to theme="select2"
to allow unselect an item. 将
allow-clear="true"
添加到ui-select-match
并将theme设置为theme="select2"
以允许取消选择项目。
<ui-select ng-model="country.selected"
theme="select2"
ng-disabled="disabled">
<ui-select-match allow-clear="true" placeholder="Select country">
{{$select.selected.name}}
</ui-select-match>
<ui-select-choices repeat="country in countries | filter: $select.search">
<span ng-bind-html="country.name | highlight: $select.search"></span>
<small ng-bind-html="country.code | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.