簡體   English   中英

ui-select angular需要一個具有空值的可選選項

[英]ui-select angular need a selectable option with null value

我正在使用ui-select angular。 我需要選擇一個具有空值的選項。 搜索了它,但找不到合適的解決方案。

 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <ui-select allow-clear ng-model="hotelsCtrl.companySelectedInsert" theme="bootstrap"> <ui-select-match placeholder="Select or search company in the list...">{{$select.selected.name}}</ui-select-match> <ui-select-choices repeat="company in hotelsCtrl.companies | filter: $select.search"> <span ng-bind-html="company.name | highlight: $select.search"></span> </ui-select-choices> </ui-select> 

有這個

最直接的方法是在將其設置為ui-select之前在hotelsCtrl.companies添加具有null值的和元素。

像這樣的東西:

   {
      name:'none',
      value:null
   }

也許如果您只想在選擇其中一個選項后就重置,請使用退格鍵

這是一個工作示例,請查看此http://jsfiddle.net/Miqe/x6bqubtw

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM