I am trying to call a service method in a controller. Here is my code. ROAService.js:
return{
loadROAValues:function(userId,roaId){
var params=JSON.stringify({userId:userId,roaId:roaId});
var promise = $http.post(url+'/'+'getROAItems',params).success(function(data){
roaDetails = data;
$log.debug("values in service class");
$log.debug("values in ROA");
$log.debug(roaDetails.id);
return roaDetails
})
.error(function(data){
roaDetails = 'error';
return roaDetails;
});
return promise;
}
}
ROAController.js:
$scope.getROA = function(roaObj){
var currentROA= {};
currentROA = ROAService.loadROAValues($scope.getMemberId(),roaObj.id);
$log.debug("values in controller");
$log.debug(currentROA.id);
}
in console I am getting these values: values in controller undefined values in service class values in ROA 342 there might be race condition . how to get the values in controller.