angular / router

The Angular 1 Component Router
MIT License
665 stars 135 forks source link

Detecting route changed #352

Open khalla opened 9 years ago

khalla commented 9 years ago

Hi, it might seem trivial, but i'm having trouble to detect when route changes. In the old router i used a listener to $routeChangeStart but now i dont know how to achieve that....

Thanks, Renato

gabrielschnegelberger commented 8 years ago

I use following code - which is taken from the Component Router itself!

$rootScope.$watch(function () {
    return $location.path();
  }, function (newUrl) {
      console.log("Navigated to " + newUrl);
      [... your own code ...]
 });