today i have an issue that i really dont understand :)
I wrote an angular service that call my api, reformatting the result and bring this data to another function into angular controller. I do this so many times, but today something goes wrong.
The reformatting-result and the data accessed to the controller is not same and i dont know (maybe understand) why :D
This is the code of service:
myApp.factory('apiService', function($http) {
var myService = {
getMunicipalityAsync : function(id) {
var promise = null;
promise = $http({
method: 'GET',
url: '/api2/cc/municipality/' + id
}).success(function(response) {
var r = {
'success': true,
'data': response.data
};
console.debug(r, 'return this');
return r;
}).error(function(data, status, headers, config) {
logError("[apiService], getMunicipalityAsync() error, with status: " + status);
});
return promise;
}
}
return myService;
});
And this is the code into the angular controller.
apiService.getMunicipalityAsync($scope.conf.geoarea).then(
function( d ) {
console.debug( d, 'return from service');
}, function( error ) {
alert('error');
});
The debug datas is not the same :(

Thanks!