问题
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