Created
November 10, 2014 07:43
-
-
Save abelorian/43ece8bb7729a29d9f3d to your computer and use it in GitHub Desktop.
Get internet status on cordova
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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