html - 在 Angular 应用程序中,<a> 中的 href 不会重新加载页面

标签 html angularjs ruby-on-rails-3 css

我有一个 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/

相关文章:

javascript - Select2 下拉菜单根本不会关闭

angularjs - 错误 : [$controller:ctrlreg] The controller with the name 'CounterController' is not registered.

javascript - Angular JS 意外标记

ruby-on-rails - rails : Keeping count of users unread notifications

javascript - 使用js的多个字符串操作

html - CSS |使div向右浮动并向父级添加滚动条

html - 列的 CSS 响应式设计顺序

javascript - angularjs $parse 字符串到 "controller as"方法

ruby - RSpec 和 ActiveRecord : Example fails on invalid scenario

ruby-on-rails - 定制产品引擎