gpt4 book ai didi

javascript - AngularJS:ui-select 一旦被选中,除了更改选项之外,无法删除所选选项

转载 作者:行者123 更新时间:2023-11-29 10:40:08 26 4
gpt4 key购买 nike

我正在使用 ui-select 从服务器获取数据并将其填充到下拉列表中(搜索和选择)。我创建了一个 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>

一旦我从选择器中选择了任何值,我就可以进一步更改。但无法删除。我怎样才能做到这一点?

最佳答案

您应该使用其他主题,如 select2 来完成这项工作。我升级了你的PLUNKER展示这是如何工作的。将 allow-clear="true" 添加到 ui-select-match 并将主题设置为 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>

关于javascript - AngularJS:ui-select 一旦被选中,除了更改选项之外,无法删除所选选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30750074/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com