重定向使用AngularJS [英] Redirect using AngularJS
问题描述
我试图使用重定向到另一个路线:
I'm trying to redirect to another route using:
$location.path("/route");
但由于某些原因,它不工作。我没有使用jQuery的用户界面和我当用户选择一个选项,我打电话从范围功能自动完成小部件。我调试它和它进入功能,但它从未重定向到另一路由。它只有当我preSS一键改变路线。
But for some reason it is not working. I did an auto-complete widget using jQuery-UI and I'm calling a function from the scope once the user selects an option. I debugged it and it enters the function but it is never redirected to the other route. It only changes the route when I press a key.
我觉得这是一种奇怪的,但我还没有想出如何解决这个问题。我用
I think it is kind of strange but I haven't figured out how to solve this. I used
window.location = "#/route";
和它的作品,但我想使用路径()
功能。
and it works but I want to use the path()
function.
没有任何人有任何想法,为什么发生这种情况?
Does anybody have any idea why this is happening?
推荐答案
随着不灵code的例子会很容易回答这个问题,但有了这些信息,我能想到的最好的是,你是调用angularjs之外$ location.path摘要。
With an example of the not working code will be easy to answer this question, but with this information the best that I can think is that you are calling the $location.path outside of the angularjs digest.
尝试在指令范围做这个应用$(函数(){$ location.path(/路径);});
这篇关于重定向使用AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!