Back button does not work when using html5Mode without <base> tag #14959
Description
Note: for support questions, please use one of these channels: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
This is a little difficult to explain so bear with me. To get to this point, a number of workarounds of existing limitations were used:
$locationProvider.html5Mode({enabled: true, requireBase: false})
is turned on. Base tag is avoided in order for<svg>
icons withxlink:href
to be used.- Since there is no base tag, in order to actually leave the SPA and go to another page on the same server, we have to manually call
location.reload()
when a URL that does not belong to our routers configured routes is detected. - After
location.reload()
, the new page loads as expected, but the back button does not work. It changes the URL, but the browser never asks the server for a page refresh.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar
http://plnkr.co/edit/LyCi3ikziOttlI7lZfCv?p=preview
To see the problem, open the plnkr demo, Read through the code a bit, and then click the link to bring you to the html5mode page. In that page, you should see another link that will bring you back to first page. Then, click the back button in your browser. It should not work!
What is the expected behavior?
I expect the browser to completely forget that Angular ever did anything to its URL change behavior when I load a new page via location.reload()
. When I load the 2nd destination page, it may be an Angular page, or it may not be. In both cases the back button should take me back to the original html5mode angular page.
What is the motivation / use case for changing the behavior?
Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
1.5.6, 1.5.7 - did not test older versions
Other information (e.g. stacktraces, related issues, suggestions how to fix)
I have noticed that if I inject $location
into the page that I expect to press the back button in, it works! But, I don't want to have to inject $location
into that page for no reason other than to fix this.