hey,
$route is used for deep-linking URLs to controllers and views (HTML partials). It watches $location.url() and tries to map the path to an existing route definition.
The Event which are available in $route service are:
- $routeChangestart
- $routeChangeSuccess
- $routeChangeError
- $routeChangeUpdate
- $locationChangeStart
- $locationChangeSuccess
In order to consume the above mentioned event use app.run() which will execute once's app is ready to run.
The following is the basic syntax that must be include to use events:
app.run(['$rootScope, function($rootScope){
$rootScope.$on($routeChangestart , function( e, curr, prev){
console.log(' In $routeChangestart');
});
$rootScope.$on($routeChangeSuccess, function( e, curr, prev){
console.log(' In $routeChangeSuccess');
});
}]);
Similarly we can use all the event available in $route provide.