AngularJS: scrollable typeahead input field

Lynob picture Lynob · Jul 28, 2016 · Viewed 9.9k times · Source

My HTML

<div class="form-group">
    <label class='control-label col-md-4' for='id_paymentCurrency'>{{'PAYMENT_CURRENCY' | translate}}</label>
    <div class='col-md-4'> 
        <div id="scrollable-dropdown-menu">
        <input type="text" class="form-control" data-trim-value="false" ng-trim="false" id ='id_paymentCurrency' ng-model="vm.data.paymentCurrency"  typeahead-append-to-body="true" required
        typeahead-editable="false"
        uib-typeahead="currency.code for currency in vm.getCurrencies($viewValue)"ng-disabled="disabled" />
    </div>   
  </div>  
</div>  

My CSS

#scrollable-dropdown-menu .tt-menu {
   max-height: 150px;
   overflow-y: auto;
 }

I'm using angular 1.x and typeahead that comes with angular-bootsrap, I can't make the scrollbar to appear.

http://fiddle.jshell.net/H7LA4/46/

Answer

Sarantis Tofas picture Sarantis Tofas · Jul 30, 2016

The problem is with your selector. Try this one:

#scrollable-dropdown-menu .dropdown-menu {
    max-height: 150px;
    overflow-y: auto;
}

You can check that it is working as expected in this fiddle