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
Post a Comment