AngularJS:ui-select 一次 selected 除了更改选项外无法删除 selected 选项

AngularJS: ui-select once selected not able to remove selected option apart from change option

我正在使用 ui-select 从服务器获取数据并将其填充到下拉列表中(搜索 & 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>

一旦我 select 从 selector 编辑了任何值,我就可以进一步更改。但无法删除。我怎样才能做到这一点?

您应该使用 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>