RobKohr
RobKohr

Reputation: 6943

How do I remove the #hash entirely from a url in angular

I have a url in angular

/something#bla

and I want to get that hash and remove it.

var hash = $location.hash();

$location.hash('');

makes the url /something#

How can I get rid of the # entirely.


Update: no I am not using # to control navigation. It is just used on an individual page to signal whether or not to show a popover. After it shows the popover, I want the # removed by the controller. Sitewide I am already using the html5Mode to do normal urls without the # mark.

Upvotes: 2

Views: 1481

Answers (1)

Ohjay44
Ohjay44

Reputation: 897

Its very simple. Make sure your $locationProvider.html5Mode(true) is set then go to your index page and set your <base href="/"> like so. Now you will no longer need the # in your URL.

Upvotes: 1

Related Questions