javascript - Angular Bootstrap Typeahead dropdown -


i have angular ui-boostrap typeahead component working correctly until added 1 requirement whole function. want call backend suggested results after user types in 3 letters. done correctly problem results visible when users type in 4th letter. there way bypass this, forcing refresh ui after user types in 3rd letter. code :

htlm  <input name="states" id="states" type="text" ng-model="vm.cityname" uib-typeahead="municipality  municipality.city + ' (' + municipality.name + ') '+municipality.zipcode municipality in vm.getmunicipalitiesbycity($viewvalue) | filter:$viewvalue | limitto:8" class="form-control" typeahead-on-select="vm.cityselected()" >  js controller vm.getmunicipalitiesbycity = function (cityname) {             if (cityname != undefined && cityname.length == 3) {                 calculationendpointservice.municipalitiesbycity({cityname: cityname}, function (result) {                     vm.municipalities = result.map(                         function (item) {                             return item;                         }                     );                 });             }             if(cityname.length<3){                 vm.municipalities=[""];             }             return vm.municipalities;         }; 

you use typeahead-min-length attribute. see https://angular-ui.github.io/bootstrap/#/typeahead


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -