Hello everyone :) Here is the problem. I'm making an angular app with:
a factory to access to an api with $http that retrieves an array of objects from a server
getObjectsFromApi : function(){ return $http({ url: 'http://path/to/the/api/', method: 'GET', headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', } }) },
and a service to compute retrieved data and inject it to controllers
this.getObjectsFromService = function(){ var objects = []; ObjectFactory.getObject() .success(function(data, status){ console.log("Successfully got objects !"); objects = data; }) .error(function(data, status){ console.log("Fail... :-("); }); return objects; };
The problem is that when I return objects, it doesn't return any data. How can I do to return $http callback data within this getObjectsFromService function ?
Thank you for helping !