I have a problem with an autocomplete and angularjs. I have several ajax request every time i type and this is unusable. I tried to use a timeout without success.. this is code:
$scope.autoCompleteResults = function(){
$scope.aborter = $q.defer();
$scope.resource = $resource(URL, {}, {
getAutocompleteResults: {
method: "GET",
timeout: $scope.aborter.promise
}
});
$scope.resource.getAutocompleteResults({}, function (data) {
if ($scope.searchTxt.length > 1) {
$scope.autocompleteViewResults = data.data;
$scope.aborter.resolve();
} else {
$scope.autocompleteViewResults = [];
$scope.search.aborter.reject();
}
});
};