AngularJS $ routeChangeSuccess回调参数 [英] AngularJS $routeChangeSuccess callback arguments
问题描述
我是新来AngularJS者,按有关事件侦听器的文档混淆。
I'm new to AngularJS and am confused by the documentation regarding event listeners.
该文件列出了以下 $ routeChangeSuccess
事件:
The documentation lists the following for the $routeChangeSuccess
event:
$ routeChangeSuccess播送后的路线依赖关系
解决。 ngView侦听指令来实例化
控制器和显示视图。
$routeChangeSuccess Broadcasted after a route dependencies are resolved. ngView listens for the directive to instantiate the controller and render the view.
类型:
广播目标:
根范围
不过,没有在那里它引用传递给回调函数的参数。然而,大多数的例子我在这里看到的,因此所有有类似的回调函数列表:
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) {
...
}
根据该AngularJS文档,所有的回调,有第一个参数为事件
。我明白了。但是哪里有接下来
和电流
来自何处?凡在任何文件中列出?
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?
推荐答案
这是在版本低于1.2看到的old文档 。但似乎他们还没有注意到,他们的播出回调签名
事件失踪。在另一方面,如果你不介意从他们的github版本库中读取,你可以检查此的 此行 为 $ routeChangeSuccess
回调的参数。
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.
更新:
对于路线
对象,你其实可以参考$路径属性<一个href=\"https://github.com/angular/angular.js/blob/master/src/ngRoute/route.js#L239\">documented这里 。
Update:
For the Route
object you can actually refer to the $route properties documented here.
这篇关于AngularJS $ routeChangeSuccess回调参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!