I am using cordova local notification its working fine but i need to send notification on specific condition within $ionicPlatform.ready. For condition, i am getting data from webservice using $http but unfortunately i am unable to retrieve data out of the $http.
$ionicPlatform.ready(function() {
var conditionvariable=“true”;
$http.get(“http://www.example.com/abc.php”).then(function(response)
{
var test = response.data[0];
if(test.result==‘test’)
{
conditionvariable=“false”;
}
});
alert(conditionvariable);
})
alert(conditionvariable); always gives true if condition is true. if i alert it just after if condition its alerts(false) right value.
thank you so much @rloui for the reply. I have tried to use js promises but no luck. I just want some value which is comes from $http.get function and i have to used it out of the $http.get function.
Saying you tried to use js promises but no luck doesn’t make sense, you are actively using promises in your example. The value that comes from $http.get is a promise. You are running into issues because you don’t know how to use them, hence me giving you an article on how to use them.