我正在使用API来获取数据并使用角度uib-typeahead进行数据显示。每当我重新加载页面并键入第一个字符时,它都不会显示任何结果。在第二笔划时,它显示第一笔划的结果,依此类推,即始终显示上一次按键的结果。谁能帮助我为什么会这样?这是我的代码:
<input type="text" ng-change="complete()" ng-disabled="disableSearch()" id="itemLookup" ng-focuser="sharedData.focusItemSearch" class="form-control" ng-model="itemObj.searchStr" bar-code ng-keydown="listenScannerInput($event)" placeholder="hello" uib-typeahead="item.upc as item.description for item in filterCountry | filter:$viewValue | limitTo:8" >
这是我的角度代码:
$scope.complete = function(item){
var output = [];
var result;
var params = {
page_size: 10,
cols: 'description1,upc',
filter: '(DESCRIPTION1,lk,"' + $scope.itemObj.searchStr + '*")'
}
ModelService.get('Inventory', params)
.then(function(result){
result = result.map(function(r) {
return {upc: r.upc, description: r.description1}
});
angular.forEach(result,function(val) {
output.push(val);
});
$scope.filterCountry = output;
});
}
任何帮助将不胜感激。谢谢