What are the $route service Events provide in AngularJs?

0 votes
Want to know  what are the events available in $route provider services and how can this event can be implemented(Syntax).
Feb 10 in Angular by kartik
• 10,760 points
35 views

1 answer to this question.

0 votes

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.

answered Feb 10 by Niroj
• 21,680 points

Related Questions In Angular

0 votes
1 answer

What is the service that is used to configure the UI-Router and ngRoute in AngularJs?

Routing comes into play whenever you want ...READ MORE

answered Feb 11 in Angular by anonymous
• 21,680 points
25 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
+1 vote
1 answer

What is the relationship between angularjs Scope with controller/view?

Let us consider the below block: <div ng-controller="emp"> ...READ MORE

answered Jan 20 in Web Development by Niroj
• 21,680 points

edited Jan 21 by Niroj 67 views
+1 vote
1 answer

What is css box module?

Hey, All the element present in html follows ...READ MORE

answered Jan 20 in Web Development by Niroj
• 21,680 points

edited Jan 21 by Niroj 53 views
0 votes
1 answer

Explain the difference between visibility:hidden; and display:none?

hii, visibility:hidden; and display:none are totally different used ...READ MORE

answered Jan 20 in Web Development by Niroj
• 21,680 points
349 views
+1 vote
1 answer

How to access the Angularjs scope of a particular html element from our console?

Hello, You should follow the below steps:-- 1.Compile and ...READ MORE

answered Jan 21 in Web Development by Niroj
• 21,680 points

edited Jan 21 by Niroj 52 views
0 votes
1 answer

What are the steps involved in ng-route in AngularJS?

Hello, As Routing is just another way of fixing some content ...READ MORE

answered Feb 6 in Angular by Niroj
• 21,680 points
39 views
0 votes
1 answer

What is $route service in AngularJs?

$route is used for deep-linking URLs to controllers ...READ MORE

answered Feb 10 in Angular by Niroj
• 21,680 points
34 views