与html5Mode Angularjs正常链接 [英] Angularjs Normal Links with html5Mode

查看:153
本文介绍了与html5Mode Angularjs正常链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与angularjs HTML 5中模式下工作。这似乎把页面上的所有HREF的控制。但是,如果我想有应用程序的同一域内的链接,但它不是真正的应用程序是什么。一个例子是一个PDF文件。

I am working with angularjs in html 5 mode. Which appears to take control of all href's on the page. But what if I want to have a link to something within the same domain of the app but not actually in the app. An example would be a pdf.

如果我这样做< A HREF =/ pdfurl> 角只是尝试使用html5mode和使用路由提供商,以确定哪些看法应该加载。但其实我是想在浏览器访问该页面的正常方式。

If i do <a href="/pdfurl"> angular will just try to use the html5mode and use the route provider to determine which view should be loaded. But I actually want the browser to go to that page the normal way.

时要做到这一点的唯一方法是使与路由提供一个规则,有一个重定向到正确的页面window.location的?

Is the only way to do this is to make a rule with the route provider and have that redirect to the correct page with window.location?

推荐答案

在HTML5模式下,有其中变量没有改写三种情况:
角文档
     -

in HTML5 mode, there are three situations in which the A tag is not rewritten: from the angular docs -


  • 包含一个目标属性链接。例如:&LT; A HREF =/转/链路A = B?TARGET =_自我&GT;链接&LT; / A&GT;

  • 指向不同的域示例绝对链接:&LT; A HREF =htt​​p://angularjs.org/&GT;链接&LT; / A&GT;

  • 以'/'链接,导致不同的基本路径时定义例如:&lt; A HREF =/否定我基地/链接&GT;链接&LT; / A&GT;

  • Links that contain a target attribute. Example: <a href="/ext/link?a=b" target="_self">link</a>
  • Absolute links that point to a different domain Example: <a href="http://angularjs.org/">link</a>
  • Links starting with '/' that lead to a different base path when base is defined Example: <a href="/not-my-base/link">link</a>

所以你的情况是1.添加目标=_自我

so your case would be 1. add target="_self"

这篇关于与html5Mode Angularjs正常链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆