javascript - How to open select box when pressing tab key? -


when pressing tab key, focus changes field. want that, when focus comes <select>, option list shown.

this working:

  <div ng-controller="typeaheadctrl">   <input type="text" /><br>     <input type="text" /><br>     <input type="text" ng-model="selected" typeahead="state state in states " />  </div> 

this not working:

<div ng-controller="typeaheadctrl">   <input type="text" /><br>     <input type="text" /><br>     <!-- not working -->     <select  ng-model="selected" >                             <option value="aa">aa</option>                             <option value="bb">bb</option>                         </select> </div> 

my plunker code here.

you take use of directive open select box on focus

directive

.directive('openselect', function(){   return{     restrict: 'ae',     link: function(scope, element, attrs){       element.on('focus', function(){         element.prop('size',element[0].options.length);       })       element.on('blur change', function(){         element.prop('size',1);       })     }   } }) 

markup

<select ng-model="selected" open-select>   <option value="aa">aa</option>   <option value="bb">bb</option> </select> 

working plunkr


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -