angular.js链接行为 - 禁用特定的URL深层链接 [英] angular.js link behaviour - disable deep linking for specific URLs
问题描述
我启用了HTML5模式工作Angular.js应用程序。
I have a working Angular.js app with HTML5 mode enabled.
$location.Html5mode(true).hashbang("!");
我想实现的是得到一些网址或< A>
标签做正常的浏览行为,而不是改变使用HTML5历史在地址栏中的URL API和采用了棱角分明的控制器处理它。
What I want to achieve is to get some URLs or <a>
tags to do the normal browsing behaviour instead of changing the URL in the address bar using HTML5 history API and handling it using Angular controllers.
我有这样的链接:
<a href='/auth/facebook'>Sign in with Facebook</a>
<a href='/auth/twitter'>Sign in with Twitter</a>
<a href='/auth/...'>Sign in with ...</a>
和我想浏览器将用户重定向到 / AUTH /...
那么该用户将被然后重定向到一个认证服务。
And I want the browser to redirect the user to /auth/...
so the user will be then redirected to an authentication service.
有没有什么办法可以做到这一点?
Is there any way I can do this?
推荐答案
添加目标=_自我
在角1.0.1作品:
Adding target="_self"
works in Angular 1.0.1:
<a target="_self" href='/auth/facebook'>Sign in with Facebook</a>
此功能是记录( https://docs.angularjs.org/guide/$location - 搜索'_self')
This feature is documented (https://docs.angularjs.org/guide/$location - search for '_self')
如果你好奇,看的角度源(线5365 @ V1.0.1)。点击劫持只发生,如果!elm.attr('目标')
是真实的。
If you're curious, look at the angular source (line 5365 @ v1.0.1). The click hijacking only happens if !elm.attr('target')
is true.
这篇关于angular.js链接行为 - 禁用特定的URL深层链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!