我有一个 Angular 应用
<html ng-app='sampApp'>
</html>
我在应用程序中有一个 anchor 链接。
<a href='/user/profile'>Redirect here</a>
但是点击 anchor 标记后页面没有重新加载。它只是调用 ajax 来呈现页面。
最佳答案
angular中使用的标准url以#开头,除非你使用的是html5模型,所以 anchor 应该是
<a href='#/user/profile'>Redirect here</a>
如果要进行全页刷新或页面重定向,则需要阻止 Angular 拦截路由。这是关于 html 链接重写的位置开发人员指南状态
Links that contain target element Example:
<a href="/ext/link?a=b" target="_self">link</a>
Absolute links that go 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>
关于html - 在 Angular 应用程序中,<a> 中的 href 不会重新加载页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26437495/