I have a function in which i am showing a confirm popup. On the basis of the response i am setting data in variable and calling a service.
var test;
$ionicPopup.confirm({
title: 'Confirm',
template: 'Are you a sure?'
}).then(function(res) {
if(res){
test = '1';
}else{
test = '2';
}
});
Service.save(entityType, function(response) {
.......
});
The problem is when popup is displayed on screen, the control move on to the next line and Service.save() is called even if user has not clicked on the popup button. It seems like it is working asynchronously. Is there any way to control this behavior.