My view has:
<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">
My controller has:
$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;
});
}
The skus
that's returned is an array like: ['1221','193A2']
.
When I type something, I get an error:
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
It then does the AJAX request for the ItemService
which has proper results, but the error stops the typeahead from functioning
Seems like I needed to return the promise, 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;
});
}