For my website, I am utilizing angular-material and integrating the auto-complete feature. In the auto-complete function (see codepen here), there is a querySearch function that filters results from a local array of demo search items.
function querySearch (query) {
var results = query ? self.repos.filter( createFilterFor(query) ) : self.repos, deferred;
return results;
}
I wanted to modify this function to make a server query after each letter typed. Following guidance on this post, I wrote Angular code to query the server and return a promise.
function querySearch (query) {
return $http.get('/ajax/user/search/' + query).then(function(data){
console.log(data);
return data.data;
});
}
However, this modification did not work as expected. The server was successfully queried, but the list of suggestions remained empty. Any assistance on resolving this issue would be greatly appreciated!