I'm trying to execute a check once promise gets fulfilled in angularjs.
request.then(function(res){
$ionicLoading.hide();
deferred.resolve(res);
}, function(res){
$ionicLoading.hide();
deferred.reject(res);
})['finally'](function(res){
alert(res)
}
)
But the alert is coming as 'undefined'.
Thanks
Edit/Update ... This is not the most awesome way of doing, but a simple and straightforward way. You need to keep track of what you want to to finally alert as you go down the chain of promises (assuming you have multiple), and just store it in a variable.
var something = null;
request.then(function(response){
$ionicLoading.hide();
something = response;
}, function(reason){
$ionicLoading.hide();
something = reason;
}).finally(function(){
alert(something);
});
A plunker to demonstrate: