Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is AngularJS duplicating the query string in my route?

I am using hash-based navigation in my AngularJS app rooted at /.

If a user navigates to my app like this:

http://example.com/?foo

A moment after the page loads, something (possibly Angular) is causing the address bar to look different than I expected.

What I saw:

http://example.com/?foo#/?foo

What I expected to see:

http://example.com/?foo#/

Why is this happening, and can I turn it off?

like image 494
djsmith Avatar asked Oct 22 '22 03:10

djsmith


1 Answers

I'd wager you need to be in 'html5 mode' to not have the hash fragment... though I'm uncertain.

http://docs.angularjs.org/guide/dev_guide.services.$location

$locationProvider.html5Mode(true).hashPrefix('!');

In your app configuration, you can mess with that config param and it'd probably get rid of it.

like image 133
RandallB Avatar answered Oct 27 '22 10:10

RandallB