I want to run a function every time any Angular controller is loaded. 

The best way I have found is to attach this handler in the first controller loaded on my site:

```
$rootScope.$on('$stateChangeSuccess', 
  function(event, toState, toParams, fromState, fromParams){
    myFunction();
  }
);

```

Is there a better alternative?