javascriptangularjsangular-ui-routerangular-uihtml5mode

ui-router html5Mode doesn't like hrefs to static html files


When using ui-router without html5Mode (using hangbang URL syntax), anchor tags that do a full page refresh to other pages (or static html content) using hrefs are working properly. As soon as I enabled html5Mode, the hrefs are updating the URL in the browser, but no server request is made.

I was under the impression that html5Mode would work like non-html5Mode in that it would respect hrefs vs ui-sref.

Am I missing something?

I've created a plunker where, if you set it to html5Mode(true), you can't navigate to the static html file. If you set html5Mode(false), you can navigate to the static html file. In both cases, all the other routing works fine.

Any ideas?

http://plnkr.co/edit/nFtjHX?p=preview

and because I need to show code when I add a plunker link, here's the config:

app.config(function($locationProvider) {
  $locationProvider.html5Mode(false);
});

Solution

  • you can use <a href="/external.html" target="_self">external</a> to perform a full page load.

    ui-router processes normal href so developers can choose to use either/or normal href/ui-sref