How to call function after service request success in Ionic

Hello. Maybe somebody can help, please. The following code returns response from an API, where the data must be loaded into a modal. Problem is the modal opens before the data is returned. Any suggestions?

Apperyio.get("srvGetCall")(requestData).then(
function(success){ // success callback
console.log(success);
$scope.fncShowLoadingAnimation('');

//wait for this to finish populating the object before opening modal
$scope.objNode = success.data;

//open modal code here
$scope fncModalResourceShow($scope.objNode.nid);

},
function(error){ // callback to handle request error
console.log('error', error)
$scope.fncShowLoadingAnimation('');
$scope.fncModNotification('Error', JSON.stringify(error.data));
},
function(notify){ // notify callback, can fire few times

});
1 person has
this question
+1
Reply