Christopher Marshall
Christopher Marshall

Reputation: 10736

$location.search empty when preceeded by hashed URL

I have query params I need to persist between routes. I have a resolve function that works using $location.search(), but when there's a hashed URL, $location.search() turns into an empty object. Is there any way to get my values out of $location.search when there's a preceding hash?

URL is: http://localhost:8080/faq#business?gmbsrc=yada&ppsrc=yada

$location.hash() returns business?gmbsrc=yada&ppsrc=yada

$location.search() returns Object {} rather than {gmbsrc: "yada", ppsrc : "yada"}

Angular: v1.2.15

Chrome: Latest.

HTML5 Mode: On

Upvotes: 4

Views: 2405

Answers (1)

anthumchris
anthumchris

Reputation: 9072

Use JS to parse out the params if you're using the "hash-first" URL format with a query string after it:

https://css-tricks.com/snippets/jquery/get-query-params-object/

Upvotes: 2

Related Questions