angularjs – 如何在选择选项后从ui-select中删除焦点

前端之家收集整理的这篇文章主要介绍了angularjs – 如何在选择选项后从ui-select中删除焦点前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
一旦用户使用鼠标单击选择了一个选项并进入开始搜索,我需要从ui-select输入中删除焦点.现在发生的事情是焦点仍然存在于select中,因此下拉列表在单击enter时打开.

<ui-select id= "country" ng-model="ctry" name= "country"  theme="bootstrap">
      <ui-select-match >{{text || $select.selected.id}}</ui-select-match>
          <ui-select-choices repeat="countryL in countryLookup | filter: $select.search">
             <div ng-bind-html="countryL.id | highlight: $select.search"></div>
                <small ng-bind-html="countryL.name | highlight: $select.search"></small>
       </ui-select-choices>

解决方法

将on-select =“onSelected($item)”添加到你的ui-select和控制器中:

$scope.onSelected = function (selectedItem) {
    setTimeout(function(){
        $(':focus').blur();
    })
}

或在控制器中使用$timeout

猜你在找的Angularjs相关文章