清除 ui-select angular 中的选定选项 [英] Clear selected option in ui-select angular
问题描述
有谁知道如何清除angular中ui-select框的选定值?
Anyone know how to clear the selected value of an ui-select box in angular?
我想要 select2 的功能,其中您在选择框中有一个小 x.看起来它没有 select2 有的允许清除方法.
I want the functionality of select2 where you have a small x in the selectbox. Doesn't look like it's got the allow-clear method that select2 got.
推荐答案
如果您使用的是 select2 主题,则 ui-select-match
上有一个 allow-clear
选项code> 指令为您执行此操作.您将在右侧看到 x,您可以通过单击它来清除它.https://github.com/angular-ui/ui-select/wiki/ui-select-match
If you are using the select2 theme there is an allow-clear
option on the ui-select-match
directive that does this for you. You will have the x on the right and you can clear it by clicking it.
https://github.com/angular-ui/ui-select/wiki/ui-select-match
快速示例:
<ui-select-match allow-clear="true" placeholder="Select or search a country in the list...">
<span>{{$select.selected.name}}</span>
</ui-select-match>
工作示例:http://plnkr.co/edit/DbbUE68QlNLjx97pBZ56?p=preview
这目前在使用引导程序或选择主题时都不起作用.
This does not currently work using either the bootstrap or selectize theme.
这篇关于清除 ui-select angular 中的选定选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!