You're misusing
replace()
- it accepts no arguments, and its purpose is said to replace the history record:If called, all changes to $location during current $digest will be replacing current history record, instead of adding new one.
You should not use replace in the first place. Instead, call
$location.url()
, it will not refresh the page (unless you passtrue
as a second argument).From the
$location
dev guide:It does not cause a full page reload when the browser URL is changed.
Angular js - replace url segments/pieces without refreshing
-
11-06-2023 - |
Question
Hi i'm trying replacing
site.com/u#asd
with
site.com/u
in browser url bar , and i would like to not refresh the page while replacing url
Is this possible?
I tryed:
$location.replace("#asd","");
but it obviously won't work
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow