问题描述
我已经建立了我的路由的角度和一切工作正常:
I have set up my routing in Angular and all works fine:
$locationProvider.html5Mode(true);
$routeProvider.
when('/', { templateUrl: '/Home/Index' }).
when('/User', { templateUrl: '/User/Index' });
不过,我现在有一个锚标记为注销按钮,这将只是把用户重定向到/用户/注销,然后注销将注销用户,并重定向到登录页面的工作。所以,我想什么是角JS只是忽略这个特定的路线,并允许它做一个正常的HTTP重定向。这似乎喜欢的事,应该是很容易的,但我一直没能找到解决问题的办法。
However I now have an anchor tag to work as a logout button which will just redirect the user to /User/Logout, and logout will then log the user out and redirect them to the login page. So what I want is for angular js to just ignore this specific route and allow it to do a normal http redirect. This seems like something that should be really easy but I haven't been able to find a solution to the problem.
我知道我可以做一个click事件,并做了click事件的window.location的变化,但似乎像一个真正哈克的方式来做到这一点。
I know I could do a click event and do a window.location change in the click event but that seems like a really hacky way to do it.
推荐答案
指定目标=_自我
在你的锚,使angularjs不重写URL。看到这里的讨论:
specify target="_self"
in your anchors, so that angularjs does not rewrite URLs. See the discussion here: http://docs.angularjs.org/guide/$location
这篇关于告诉角度JS来忽略特定路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!