Created
July 31, 2016 14:50
-
-
Save guptasanchit90/9e607fe97caef04355d1105c6a8b0867 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
app.run(function($window, $rootScope) { | |
$rootScope.online = navigator.onLine; | |
/** | |
Generate event offline when user disconnects from Internet | |
$scope.$watch('offline', function(newStatus) { ... }); | |
**/ | |
$window.addEventListener("offline", function() { | |
$rootScope.$apply(function() { | |
$rootScope.online = false; | |
}); | |
}, false); | |
/** | |
Generate event online when user connects from Internet | |
$scope.$watch('online', function(newStatus) { ... }); | |
**/ | |
$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