簡體   English   中英

角式靴帶提前關閉選擇

[英]angular bootstrap typeahead close select

當表單提交的值不在列表中時,我想關閉選擇列表(使用typeahead-focus-first)。 我用預輸入 plunker例如作為起點。

當用戶按下Enter鍵時,storeItem函數將觸發,但列表不會關閉。

<form ng-submit="storeItem()">
  <input type="text"
    typeahead="state for state in states | filter:$viewValue | limitTo:8" 
    typeahead-focus-first="false"/>
</form>

提交功能:

$scope.storeItem = function() {
   $scope.selected = Date.now();
};

在這里查看完整的插件

如何在保持輸入值和列表完整的同時關閉列表?

似乎您發現了一個錯誤。 感興趣的區域位於typeahead指令中-element.bind('keydown'方法。當按下enter或tab鍵並且未選擇任何內容時,存在不關閉下拉菜單的邏輯:

// if there's nothing selected (i.e. focusFirst) and enter is hit, don't do anything
if (scope.activeIdx == -1 && (evt.which === 13 || evt.which === 9)) {
  return;
}

輸入元素失去焦點,彈出窗口不會關閉。 您應該在回購上開一個問題。

暫無
暫無

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

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