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

前端 未结 1 2007
耶瑟儿~
耶瑟儿~ 2020-12-24 12:50

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

They are both undocumented events related to window.l

相关标签:
1条回答
  • 2020-12-24 13:27

    The $locationChangeStart is fired when AngularJS starts to update browser's location based on mutations done via $location service ($location.path(), $location.search()).

    It might happen that an application will listen to the $locationChangeStart event and will call preventDefault() on it. In this case the second event ($locationChangeSuccess) won't be broadcasting.

    In short: $locationChangeStart fires when the location gets updated. It is followed by $locationChangeSuccess if the first action wasn't prevented.

    Relevant bits of the source code are here: https://github.com/angular/angular.js/blob/2508b47c1a34dfc834f8fde858574f81af4d287e/src/ng/location.js#L598

    0 讨论(0)
提交回复
热议问题