0

I'm trying to build a custom URL and update the URL as the user selects items in my dashboard.

For example, after clicking a few items the URL could/should look like:

#/dashboard?&portfolio=GOOG&ticker1=GOOG

Currently the URL only ends in /dashboard (console.log($location.path());)

How would I update the $location.path() to add params like so? There's plenty of questions/answers and guides on getting params from the URL, but how would you update the URL in the first place?

Say if you want to add the following:

  • ?&portfolio=GOOG&ticker1=GOOG

2 Answers 2

2

just organize your params in an object, like

var params = {
   portfolio: GOOG,
   ticker1:GOOG
}

and use,

$location.url('/dashboard ').search(params);

Hope it helps !!!

Sign up to request clarification or add additional context in comments.

3 Comments

Cool I see this! #/dashboard?portfolio=GOOG&ticker1=GOOG
That wouldn't be a valid query string if you did that
I like this solution as it does exactly what I am trying to do. I am trying to create a custom query string that I can bookmark and read back in the properties when the link is shared.
0

I think I'm understanding what you're saying. I believe you could use a PHP GET function to do that. A GET function in PHP will add the information you're trying to communicate to the backend to the URL, while the POST function does not.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.