I need to call a service function when a certain value exists. I call a service, get data and then I need to call another service to make some string operations on the result of the first service call.
Actually I simly check when the calls to first service are finished, but not seems a good way to do this.
$scope.result = function(){
Report.startQueue(url, function(response, reports){
$scope.progress = response;
$scope.report = reports;
if(response === "last"){
$scope.string= keyService.stringOperations($scope.report.MyString);
}
});
}
If instead I call directly
$scope.string= function(item) {
return keyService.stringOperations(item);
}
I got errors because the string is not ready at the moment. In the keyService I use the string replace method, that throws error if the string is empty
[PLUNKR] http://plnkr.co/edit/gcvOZL