Conditionally have anchor links send user to a different page, rather than load to ng-view

前端 未结 1 462
清酒与你
清酒与你 2020-12-06 20:24

I have a view that contains an anchor link. That link has an href to another url in my site. Angular tries to load that site, using html5mode. I would rather just have de

相关标签:
1条回答
  • 2020-12-06 20:42

    AngularJS understands a few rules that will make the browser perform a full reload. The rules are documented under the 'Html link rewriting' section in the $location service documentation.

    From the documentation:

    In cases like the following, links are not rewritten; instead, the browser will perform a full page reload to the original link.

    • 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>

    Note that the last example only works if you have used the base element in the head section of your page:

    <base href="/my-base/" />
    
    0 讨论(0)
提交回复
热议问题