170
rated 0 times
[
172]
[
2]
/ answers: 1 / hits: 19194
/ 11 Years ago, thu, january 30, 2014, 12:00:00
I want to have some event listener code in my AngularJS app which will apply to the scope of all controllers.
I basically want to define the following somewhere:
document.addEventListener(online, onOnline, false);
document.addEventListener(offline, onOffline, false);
function onOnline() {
console.log(just got online event);
$scope.noNetwork = false;
}
function onOffline() {
console.log(just got offline event);
$scope.noNetwork = true;
}
which will receive events no matter which controller scope is currently active.
More From » angularjs