Angular-ui 仅在退格时提前输入正确的结果
Angular-ui typeahead giving correct results only on backspace
我正在使用 Angular-UI typeahead,它工作正常,但我有一个奇怪的行为,当我按退格键时,它会给出正确的结果。
假设我正在输入
sector 4
然后它给出的结果是
Sector 1
Sector 2
Sector 4
Sector 5
但是当我按退格键时,它给出了正确的结果
Sector 4
Sector 42
Sector 42a
Sector 47
我的 HTML 代码是
<input class="location-input" ng-model="Constants.loc" typeahead="loc.title for loc in loc_getdat()" typeahead-min-length="1">
我的控制器代码是
$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
});
}
}
我哪里做错了?
得到解决方案。
这是关于提前输入的等待时间。服务器需要一些时间来显示结果,因此在库文件中,提前输入从 0 毫秒开始。我将 typeaheadWaitMs
时间从 0
更改为 50
。
(k.typeaheadWaitMs)||50
现在一切正常。
我正在使用 Angular-UI typeahead,它工作正常,但我有一个奇怪的行为,当我按退格键时,它会给出正确的结果。
假设我正在输入
sector 4
然后它给出的结果是
Sector 1
Sector 2
Sector 4
Sector 5
但是当我按退格键时,它给出了正确的结果
Sector 4
Sector 42
Sector 42a
Sector 47
我的 HTML 代码是
<input class="location-input" ng-model="Constants.loc" typeahead="loc.title for loc in loc_getdat()" typeahead-min-length="1">
我的控制器代码是
$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
});
}
}
我哪里做错了?
得到解决方案。
这是关于提前输入的等待时间。服务器需要一些时间来显示结果,因此在库文件中,提前输入从 0 毫秒开始。我将 typeaheadWaitMs
时间从 0
更改为 50
。
(k.typeaheadWaitMs)||50
现在一切正常。