我的观点有:
<input type="text" ng-model="receivingSku" placeholder="Locations loaded via $http" typeahead="sku for sku in getSku($viewValue) | filter:$viewValue" typeahead-on-select="selectedSku()" class="form-control">
我的控制器有:
$scope.getSku = function(skuValue) {
ItemService.search(CompanyService.getCompany()._id, skuValue).then(function(response) {
var skus = response.data.items.map(function(e) {
return e.sku;
});
return skus;
});
}
返回的skus
是一个数组,如:['1221','193A2']
。
当我输入内容时,我收到错误:
Error: matches is undefined .link/getMatchesAsync/<@http://localhost:3000/lib/angular-bootstrap/ui-bootstrap-tpls.js:3186 zd/e/l.promise.then/A@http://localhost:3000/lib/angular/angular.min.js:93 zd/e/l.promise.then/A@http://localhost:3000/lib/angular/angular.min.js:93 zd/g/<.then/<@http://localhost:3000/lib/angular/angular.min.js:94 Ad/this.$get</h.prototype.$eval@http://localhost:3000/lib/angular/angular.min.js:102 Ad/this.$get</h.prototype.$digest@http://localhost:3000/lib/angular/angular.min.js:100 Ad/this.$get</h.prototype.$apply@http://localhost:3000/lib/angular/angular.min.js:103 pb/h@http://localhost:3000/lib/angular/angular.min.js:126 Yc/c/<@http://localhost:3000/lib/angular/angular.min.js:27 q@http://localhost:3000/lib/angular/angular.min.js:7 Yc/c@http://localhost:3000/lib/angular/angular.min.js:27
然后它对ItemService
的AJAX请求有正确的结果,但是错误阻止了预先输入
答案 0 :(得分:2)
似乎我需要回复承诺,ala:
$scope.getSku = function(skuValue) {
return ItemService.search(CompanyService.getCompany()._id, skuValue).then(function(response) {
var skus = response.data.items.map(function(e) {
return e.sku;
});
return skus;
});
}