In an angular app, href in <a> doesn't reloads the page

此生再无相见时 提交于 2020-01-15 08:38:32

问题


I have an angular app

<html ng-app='sampApp'>
</html>

I have an anchor link inside the app.

<a href='/user/profile'>Redirect here</a>

But the page is not getting reloaded on clicking the anchor tag. It just makes an ajax call to render the page.


回答1:


Standard url used in angular start with #, unless you are using html5 model, so the anchor should be

<a href='#/user/profile'>Redirect here</a>

If you want to do full page refresh or page redirect, then you need to stop Angular from intercepting the route. Here is what location developer guide state regarding html link rewriting

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>



来源:https://stackoverflow.com/questions/26437495/in-an-angular-app-href-in-a-doesnt-reloads-the-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!