Shikhar
Shikhar

Reputation: 971

Angular-ui typeahead giving correct results only on backspace

I am using Angular-UI typeahead which works fine, but I am having a strange behaviour that when I press backspace, then it gives the correct results.


Let's say that I am typing

sector 4

Then it gives the result as

Sector 1
Sector 2
Sector 4
Sector 5

But when I press backspace, it gives the correct result as

Sector 4
Sector 42
Sector 42a
Sector 47

My HTML code is
<input class="location-input" ng-model="Constants.loc" typeahead="loc.title for loc in loc_getdat()" typeahead-min-length="1">

And my controller code is

$scope.loc_getdat = function() {
if ($scope.Constants.loc.length > 1) {
    return $http.get('/api/v2/location_auto_suggest?loc=' + $scope.Constants.loc)
        .then(function(response) {
            return response.data.location_search
        });
    } 
}

Where am i doing wrong?

Upvotes: 1

Views: 412

Answers (1)

Shikhar
Shikhar

Reputation: 971

Got the solution. It was regarding the wait time of the typeahead. The server takes a bit of time to show results, so in the library file, the typeahead started at 0 milliseconds. I changed the typeaheadWaitMs time from 0 to 50.

(k.typeaheadWaitMs)||50

Now it is working fine.

Upvotes: 2

Related Questions