title: Angular: Order of custom event handlers & default handler
body: <p>In my application, I am defining a custom event for which I wish to have default handler in place. If any controller/service wants to override default handling, they can do so by adding their own handler. </p>
  
  <p>For implementing this scenario, I added default handler on $rootScope &amp; broadcast the event on $rootScope. I am expecting something like following to work.</p>
  
  <pre><code>//defined in .run block
  $rootScope.$on('customEvent', defaultHandler);
  
  //defined inside a controller
  $scope.$on('customEvent', function customHandler(e){
      // handle event
      e.preventDefault();
  });
  </code></pre>
  
  <p>My problem is since .run block gets executed before any controller is executed, the defaultHandler always gets registered first. As a result, it gets executed first &amp; then the custom handler gets executed. I want the defaultHandler to be executed at the last. </p>
  
  <p>I want to avoid adding my own logic of maintaining event handlers list &amp; ensuring that they execute in desired order. Is there any way of achieving this in angular? Thanks.</p>