Previously, I used html5mode
in my mean-stack website, now I want to disable it for some reasons, so I comment $locationProvider.html5Mode(true)
in my code and still leave <base href="/1/" />
in index.html
.
As a result, https://localhost:3000/1/#/home
in a browser works.
However, clicking on a button defined by the following html leads to https://localhost:3000/1/edit/
, rather than https://localhost:3000/1/#/edit/
.
<li><a href="edit/" target="_self">New</a></li>
Does anyone know how to modify the html such that it opens https://localhost:3000/1/#/edit/
?
Since you're no longer using html5mode, I would recommend prepending the hrefs with #/
in order to preserve your endpoints.
<li><a href="#/edit/" target="_self">New</a></li>
Without html5mode, the desired link will now cause a full page refresh. If you aren't using html5, why do you need the #
?
It may be worth adjusting the urls to follow this pattern https://localhost:3000/1/edit/
, unless you'd rather use my suggested code above. There may be a more elegant solution of course.