清除ui-select角度中的选定选项 [英] Clear selected option in ui-select angular

查看:119
本文介绍了清除ui-select角度中的选定选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何清除Angular用户界面选择框的选定值吗?

Anyone know how to clear the selected value of an ui-select box in angular?

我想要select2的功能,其中selectbox中有一个小x.看起来好像没有select2拥有的allow-clear方法.

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选项可以为您执行此操作.您将在右侧看到x,可以通过单击将其清除. https://github.com/angular-ui/ui-选择/维基/用户界面选择匹配

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角度中的选定选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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