title: how to check internet connection on button tap in ionic?
body: <p>i'm trying to check for an internet connection once the login button is tapped but so far when the button is tapped, the app doesnt go through the next page but it also doesnt display the alert box. how to do it in ionic/angularjs? here's my code: </p>
  
  <pre><code> 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: '&lt;input type="password" ng-model="userdata.passwordChange"&gt;',
                      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');
  }
  </code></pre>