我是ionic1框架的新手,並且在sidemenu離子應用上工作。我正在使用cordova local notification
其工作正常,但我需要在$ionicPlatform.ready
的特定條件下發送通知。對於條件,我使用$http
從webservice獲取數據,但不幸的是,我無法從$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);
})
我無法從功能$http.get
函數中獲取數據。如果我試圖警告它出警報功能undefined
請幫助如何獲取數據。
這已被問及(並回答)至少在單獨的Stackoverflow上千次。 – jcaron
[我如何從異步調用返回響應?](http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – jcaron