Good afternoon. I want to use md-autocoplete of angular-material but it throws me the following error:
angular.js: 13920 TypeError: Can not read property 'then' of undefined at fetchResults (angular-material.js: 23331)
at handleQuery (angular-material.js: 23437)
at MdAutocompleteCtrl.focus (angular-material.js: 23022)
at fn (eval at compile (angular.js: 14817),: 4: 415)
at expensiveCheckFn (angular.js: 15906)
at callback (angular.js: 25885)
at ChildScope. $ eval (angular.js: 17682)
at ChildScope. $ apply (angular.js: 17782)
at HTMLInputElement. (angular.js: 25890)
at HTMLInputElement.dispatch (jquery.js: 5110)
the autocomplete code is this:
<md-autocomplete md-selected-item="selectedItem" md-search-text="searchText" md-items="item in getMatches(searchText)" md-item-text="tickets.rut">
<span md-highlight-text="searchText">{{tickets.rut}}</span>
</md-autocomplete>
and that of my controller is this:
$http({
method: 'POST',
url: 'http://localhost/Paneldetencion/app/php/consulta.php',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
})
.then(function(data) {
var dat = data.data;
$scope.tickets= [];
for (var i = 0; i < dat.length; i++) {
var ticket = {numero : dat[i].numero,
rut : dat[i].rut,
servicio_id : dat[i].servicio_id};
$scope.tickets.push(ticket);
}
});
Here when doing a console.log($scope.tickets);
the data shows them like this:
How can I solve it?