Clear selected option in ui-select angular

前端 未结 4 534
一生所求
一生所求 2020-12-24 05:01

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

I want the functionality of select2 where you have a small x in the selectbox. Doesn\'t l

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-24 05:34

    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

    Quick example:

    
      {{$select.selected.name}}
    
    

    Working example: http://plnkr.co/edit/DbbUE68QlNLjx97pBZ56?p=preview

    This does not currently work using either the bootstrap or selectize theme.

提交回复
热议问题