I have been pulling my hair out here. I am using ion-autocomplete and want to pull data with a factory.
My Factory ...
myApp.factory('items', function($http){
return {
list: function(query,callback){
$http.get('http://192.168.100.100/myApp/products/' + query).success(callback)
}
};
});
To get the data I use ..
items.list(function(items) {
$scope.items = items;
});
The demo for autocomplete request data like ..
$scope.getTestItems = function (query) {
return {
items: [
{id: "1", name: query + "1", view: "view: " + query + "1"},
{id: "2", name: query + "2", view: "view: " + query + "2"},
{id: "3", name: query + "3", view: "view: " + query + "3"}]
};
};
So I figure this is a workable solution ..
$scope.getTestItems = items.list(query,function(items)
{
console.log(items);
return items;
}
)
but clearly is not. I have tried ..
$scope.getTestItems = function(query)
{
items.list(query,function(items)
{
console.log(items);
return items;
}
)
}
Which does give me a console of the result but this is not returned to getTestItems