AngularJS - 检测,拖延,并取消路由变化 [英] AngularJS - Detecting, stalling, and cancelling route changes
本文介绍了AngularJS - 检测,拖延,并取消路由变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以看到事件 $ routeChangeStart
在我的控制器,但我不明白怎么告诉角留下来。我需要弹出类似你想保存,删除或取消?并保持当前的页。如果用户选择取消。我不明白,让听众取消路线变化的任何事件。
I can see the event $routeChangeStart
in my controller, but I don't see how to tell Angular to stay. I need to popup something like "Do you want to SAVE, DELETE, or CANCEL?" and stay on the current "page" if the user selects cancel. I don't see any events that allow listeners to cancel a route change.
推荐答案
您正在收听的错误时,我做了一些谷歌上搜索,但无法找到的文档任何东西。这方面的一个快速测试:
You are listening to the wrong event, I did a bit of googling but couldn't find anything in the docs. A quick test of this:
$scope.$on("$locationChangeStart", function(event){
event.preventDefault();
})
在全局控制器$ P $更改pvented的位置。
In a global controller prevented the location from changing.
这篇关于AngularJS - 检测,拖延,并取消路由变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文