0

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

itsme
  • 48,972
  • 96
  • 224
  • 345

1 Answers1

1
  1. 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.

  2. You should not use replace in the first place. Instead, call $location.url(), it will not refresh the page (unless you pass true as a second argument).

    From the $location dev guide:

    It does not cause a full page reload when the browser URL is changed.

Eliran Malka
  • 15,821
  • 6
  • 77
  • 100