AngularJS html5mode with links back to server

Having enabled successfully enabled html5mode on my web application, I accidentally broke a browser link to download some JSON from the server, since Angular now interprets it as a route.

Thanks to http://blog.panjiesw.com/posts/2013/09/angularjs-normal-links-with-html5mode/ for posting an explaining a full answer.

Adding target=”_self” to the link fixes it but here are the options from the Angular docs

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
    Example: <a href="/not-my-base/link">link</a>

Leave a Reply

Your email address will not be published. Required fields are marked *