title: AngularJS controller/service/http communication
body: <p>I've wrapped up my REST API in an AnguarJS service that gets injected into controllers. Pretty standard, right. Now I'd like that service to intercept any 401 response and somehow trigger a logout or re-login prompt or something. The problem is: that service doesn't have access to any scope. What is the best way to broadcast that error? I've come up with a few ideas, but I'm new to Angular and am wondering if anyone can tell me the "Angular" way of doing this?</p>
  
  <p>1) I could have the service act as an event pool that my AppCtrl can listen to. But this seems a bit overly complicated. So:</p>
  
  <pre><code>myService.on('logout', function() { 
      $scope.isLoggedIn = false;
  });
  </code></pre>
  
  <p>2) I can inject the $rootScope into the service, and have the service modify <code>isLoggedIn</code> directly. But this just seems plain wrong. I'd like to keep clear distinctions where services service data, controllers control the scope, and directives muck with the dom.</p>
  
  <p>3) Every one of my controllers could watch for a rejected promise and if the reason is a 401 error, then reach up the $scope and set <code>isLoggedIn</code> to false, but this option just sucks, obviously.</p>
  
  <p>Any help?</p>
  
  <p>Thanks.</p>