title: How to unbind an external event when a controller/$scope is destroyed?
body: <p>Supposed I have a controller for a page that is being rendered into an <code>ng-view</code>.</p>
  
  <p>This controller binds to some events of an external source (such as an application-wide message bus) to update its model. This basically works very easy:</p>
  
  <pre><code>function MyController ($scope) {
    $scope.bar = '…';
  
    externalSource.on('foo', function (data) {
      $scope.$apply(function () {
        $scope.bar = data.bar;
      });
    });
  }
  </code></pre>
  
  <p>The problem is: How do I unbind the controller from the external source once the view it it is associated with is not longer shown?</p>
  
  <p>Is there something such as a <code>dispose</code> event or something similar?</p>
  
  <p>Or is my approach completely wrong, and I should deal with something like that somehow else? If so, how?</p>