私はcordovaネットワーク情報プラグインをインストールしており、ログイン時にユーザーを検証する次のコードを持っています。しかし、私はそれがユーザーの資格情報を検証する前にインターネット接続を確認したい。どのようにイオンでこれを行うには?ボタンクリックでインターネット接続をチェックする方法は?
$scope.enterLogin = function(usern,pass)
{
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.');
}
}
}
});
}
「navigator.connection.type」を使用してネットワークを取得するか、「navigator.online」 –