Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS $routeChangeSuccess callback arguments

I'm new to AngularJS and am confused by the documentation regarding event listeners.

The documentation lists the following for the $routeChangeSuccess event:

$routeChangeSuccess Broadcasted after a route dependencies are resolved. ngView listens for the directive to instantiate the controller and render the view.

Type:

broadcast Target:

root scope

However, no where does it reference any arguments that are passed to the callback function. And yet, most of the examples I've seen here on SO all have a similar callback function listing:

$rootScope.$on("$routeChangeSuccess", function(event, next, current) {
   ...
});

According to the AngularJS docs, all callbacks have the first argument as the event. I get that. But where are next and current coming from? Where is that listed in any of the documentation?

like image 970
Eric B. Avatar asked Jul 24 '14 16:07

Eric B.


1 Answers

It was documented in version less than 1.2 see this old documentation. But it seems they haven't noticed that the callback signatures for their broadcast events are missing. On the other hand, if you don't mind reading from their github repository you can check this line here for the $routeChangeSuccess callback parameters.

Update: For the Route object you can actually refer to the $route properties documented here.

like image 190
ryeballar Avatar answered Nov 17 '22 11:11

ryeballar