I try to use angular-bootstrap's typeahead plugin with $http service.At first, I use $http.success() like this:
$scope.filterProvinces = function(val){
return service.provinceList({
pageSize : 10,
queryKey : val
}).success(function(data, status, headers, config){
return data.data.list;
}
).error(function(data, status, headers, config){
alert("no result!");
return ;
});
}
but it didn't work, so I change the code , like this:
$scope.filterProvinces = function(val){
return service.provinceList({
pageSize : 10,
queryKey : val
}).then(function(response){
return response.data.data.list;
});
}
and it was working, so I was confused. Why then() is ok but success() is not right.
successanderrorare not standard promise methods. See docs.angularjs.org/api/ng/service/$http#deprecation-notice