我想在 $location
更改之前运行转换,在 vanilla JS 中我可以选择不处理 onhashchange
或 pushstate
更新直到我准备好,但是我如何在 AngularJS 中实现这一点?
最佳答案
看看 $locationChangeStart(您可能还想查看许多其他事件:$locationChangeSuccess、$includeContentLoaded、$viewContentLoaded、$routeChangeStart、$routeChangeError、$routeUpdate、$routeChangeSuccess。
$scope.$on("$locationChangeStart", function (event, nextLocation, currentLocation) {
// Do things here and then you can use event.preventDefault()
});
关于AngularJS 暂停 $location 更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17996293/