我試圖檢查互聯網連接,一旦登錄按鈕被點擊,但到目前爲止,當按鈕被點擊,應用程序不會通過下一頁,但它也不會顯示警告框。如何在離子/ angularjs中做到這一點?這裏是我的代碼:如何檢查離子按鈕上的互聯網連接?
if (navigator.onLine) {
userFactory.getUser(usern).then(function(response)
{
if(JSON.stringify(response.data) === "null")
{
alert('Please sign-up for an account.');
}
else
{
if(pass === response.data.Password)
{
var myPopup = $ionicPopup.show({
template: '<input type="password" ng-model="userdata.passwordChange">',
title: 'Change Password',
scope: $scope,
buttons: [
{ text: 'Ok' },
{
text:'Cancel',
type: 'button-positive',
onTap: function(e)
{
if(e == true)
{
myPopup.close();
}
else
{
$location.path('/page17');
console.log($location.path());
myPopup.close();
}
}
}
]
});
}
else
{
if(pass == $scope.userdata.passwordChange)
{
$location.path('/page9');
}
else if(pass == "omar_1992!")
{
$location.path('/page9');
}
else
{
alert('Login failed. Please check your credentials.');
}
}
}
});
}else{
alert('no internet connection');
}
您好,我嘗試過,但彈出框犯規露面.. –
什麼是你得到的錯誤? – Aravind