Skip to content

Instantly share code, notes, and snippets.

@abelorian
Created November 10, 2014 07:43
Show Gist options
  • Save abelorian/43ece8bb7729a29d9f3d to your computer and use it in GitHub Desktop.
Save abelorian/43ece8bb7729a29d9f3d to your computer and use it in GitHub Desktop.
Get internet status on cordova
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
});
app.run(function($window, $rootScope) {
$rootScope.online = navigator.onLine;
$window.addEventListener("offline", function () {
$rootScope.$apply(function() {
$rootScope.online = false;
});
}, false);
$window.addEventListener("online", function () {
$rootScope.$apply(function() {
$rootScope.online = true;
});
}, false);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment