-
-
Save pyadav/f3dd711f71d2ab31e50cf0995c651757 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