一个人如何监视/触发路线变化的事件?
ask by Robert Christian translate from soNote : This is a proper answer for a legacy version of AngularJS.
(注意 :这是旧版本AngularJS的正确答案。)
See this question for updated versions.(有关更新的版本,请参阅此问题 。)
$scope.$on('$routeChangeStart', function($event, next, current) {
// ... you could trigger something here ...
});
The following events are also available (their callback functions take different arguments):
(以下事件也可用(它们的回调函数采用不同的参数):)
($ routeChangeSuccess)
($ routeChangeError)
($ routeUpdate-如果将reloadOnSearch属性设置为false)
See the $route docs.
(请参阅$ route文档。)
There are two other undocumented events:
(还有其他两个未记录的事件:)
($ locationChangeStart)
($ locationChangeSuccess)
See What's the difference between $locationChangeSuccess and $locationChangeStart?