title: Run a function every time an Angular controller is loaded
body: <p>I want to run a function every time any Angular controller is loaded. </p>
  
  <p>The best way I have found is to attach this handler in the first controller loaded on my site:</p>
  
  <pre><code>$rootScope.$on('$stateChangeSuccess', 
    function(event, toState, toParams, fromState, fromParams){
      myFunction();
    }
  );
  </code></pre>
  
  <p>Is there a better alternative?</p>