How to watch for a route change in AngularJS

How would one watch/trigger an event on a route change?

Note : this is a proper answer for a legacy version of Angular, see this question for updated version

$scope.$on('$routeChangeStart', function(next, current) { 
   ... you could trigger something here ...
 });

The following events are also available (their callback functions take different arguments):

  • $routeChangeSuccess
  • $routeChangeError
  • $routeUpdate - if reloadOnSearch property has been set to false

See the $route docs.

There are two other undocumented events:

  • $locationChangeStart
  • $locationChangeSuccess

See What's the difference between $locationChangeSuccess and $locationChangeStart?