Skip to content

Instantly share code, notes, and snippets.

@pfallasro
Created December 10, 2015 15:25
Show Gist options
  • Save pfallasro/51a839a0f2444a25fde9 to your computer and use it in GitHub Desktop.
Save pfallasro/51a839a0f2444a25fde9 to your computer and use it in GitHub Desktop.
Plugin Desconexion
var noInternetPopup = null;
$scope.showPopup = function() {
noInternetPopup = $ionicPopup.show({
template: '<p>Por favor verifique que el servicio de red esté habilitado.</p>',
title: 'No hay conexión a internet',
scope: $scope
});
};
$scope.closePopup = function () {
noInternetPopup.close();
};
document.addEventListener("deviceready", function () {
// listen for Online event
$rootScope.$on('$cordovaNetwork:online', function(event, networkState){
var onlineState = networkState;
$scope.closePopup();
});
// listen for Offline event
$rootScope.$on('$cordovaNetwork:offline', function(event, networkState){
var offlineState = networkState;
//alert('Deconectado');
$scope.showPopup();
})
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment