Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

一个人如何监视/触发路线变化的事件?

  ask by Robert Christian translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
431 views
Welcome To Ask or Share your Answers For Others

1 Answer

Note : 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

    ($ routeChangeSuccess)

  • $routeChangeError

    ($ routeChangeError)

  • $routeUpdate - if reloadOnSearch property has been set to false

    ($ routeUpdate-如果将reloadOnSearch属性设置为false)

See the $route docs.

(请参阅$ route文档。)

There are two other undocumented events:

(还有其他两个未记录的事件:)

  • $locationChangeStart

    ($ locationChangeStart)

  • $locationChangeSuccess

    ($ locationChangeSuccess)

See What's the difference between $locationChangeSuccess and $locationChangeStart?

(请参阅$ locationChangeSuccess和$ locationChangeStart有什么区别?)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...