3

我正在使用 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>

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

4

1 回答 1

4

您应该使用其他主题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>
于 2015-06-10T07:56:25.210 回答