Sushil Kumar Sushil Kumar - 1 year ago 217
AngularJS Question

How to detect route change in Angular 1.5 component router?

I am using angular 1.5 component router in my application. Is there a way to detect route change in component router. I want to run some code on route change.

Answer Source

Sajeetharan s' answer is correct but its only for current scope.If you want it for every state change add it like this

run.$inject = ['$rootScope', '$location', '$cookieStore', '$http'];

   function run($rootScope, $location, $cookieStore, $http) {
     $rootScope.$on('$locationChangeStart', function(event, next, current) {


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download