Angular UI bootstrap - show dropdown on typeahead-no-results

Thomas picture Thomas · Oct 24, 2015 · Viewed 15.7k times · Source

tryng to get a dropdown when no result on typeahead but, the drop down menu dosen't show view

<div class="dropdown">
    <div class="form-group">
       <input placeholder="Vælg kunde" type="text" ng-model="customer"  typeahead-editable="false" uib-typeahead="customer as customer.customer for customer in customers | filter:$viewValue | limitTo:8" class="form-control"
            typeahead-popup-template-url="customPopupTemplate.html"
            typeahead-min-length="0"
            typeahead-no-results="noResults">
    </div>

    <div ng-if="noResults" dropdown-toggle>
       <ul class="dropdown-menu" >
           <li><a href="#">No result</a></li>
       </ul>
    </div>

</div>

removing class="dropdown-menu" gives me the li with no result, but i dont get it as a dropdown menu

who do i toggle this dropdown menu on no result ?

Answer

davidkonrad picture davidkonrad · Oct 24, 2015

The problem is that the dropdown never is triggered, and by that not rendered properly. You are just making the markup visible.

You can set auto-close="disabled" and is-open="true" to show the dropdown properly upon noResults :

<div class="form-group"> 
  <input placeholder="Vælg kunde" type="text" ng-model="customer" typeahead-editable="false" uib-typeahead="state for state in states | filter:$viewValue | limitTo:8" class="form-control" typeahead-min-length="0" typeahead-no-results="noResults">

   <span ng-if="noResults" auto-close="disabled" is-open="true" uib-dropdown uib-dropdown-toggle>
      <ul class="uib-dropdown-menu" >
        <li><a href>no results</a></li>
      </ul>
    </span>

</div>

working demo -> http://plnkr.co/edit/4vVznXyjZo3HuIb2p5as?p=preview

NB: The plnkr is using ui-bootstrap version 0.14.3, if you are using a version prior to 0.14.0 then do not append uib- prefixes.