AngularJS:UI的选择一旦选定不能从改变选项除了删除选定的选项 [英] AngularJS: ui-select once selected not able to remove selected option apart from change option

查看:494
本文介绍了AngularJS:UI的选择一旦选定不能从改变选项除了删除选定的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的用户界面,请从服务器和安培获取数据;填充它在下拉(搜索和;选择)。我创建了一个 plunker 你。

I am using ui-select for fetching data from server & populate it in drop down (search & select). I created a plunker for you.

<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?

推荐答案

您应该使用其他主题如选择2 来完成这项工作。我升级了您的 PLUNKER 显示这是如何工作的。添加允许清晰=真正的 UI的选择匹配,并设置主题为主题=选择2允许取消选择一个项目。

You should use an other theme like select2 to make this work. I upgraded your PLUNKER to show how this could work. Add allow-clear="true" into ui-select-match and set theme to theme="select2" to allow unselect an item.

<ui-select ng-model="country.selected" theme="select2" ng-disabled="disabled" style="width: 300px;">
      <ui-select-match allow-clear="true" 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>

这篇关于AngularJS:UI的选择一旦选定不能从改变选项除了删除选定的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆