title: Where do I put event listener code in AngularJS that all controller use?
body: <p>I want to have some event listener code in my AngularJS app which will apply to the scope of all controllers.</p>
  
  <p>I basically want to define the following somewhere:</p>
  
  <pre><code>    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;
      }
  </code></pre>
  
  <p>which will receive events no matter which controller scope is currently active. </p>