I have read about "promise" object and all the ways to get some sort of async call or wait until a http call is done, but I haven't been able to success. This is what I got and what I'm trying to do:
I need to get some json file from my server and use the data from that json in my code (js file) and not only as data for my HTML template.
I have a service that does the call to the json file:
mobilityApp.service('serveiWebservices', function($resource) {
return {
getWS: function($scope) {
var path = 'jsonWS/context.json';
$resource(path).get(function (data) {
console.log(data); //data is printed fine
$scope.returnData = data; //just to test, it doesn't work neither
return data;
});
}
};
});
And from my controler I call it like this:
var data = serveiWebservices.getWS($scope);
console.log(data); //undefined
any idea on how to work with the promise object that the funcion returns and perform actions as soon as it gets the requested data ? i Know that I could set a "success" function but I would like not to use callbacks.
Tnanks in advance !