2

I'm using UI-Router to manage the states of my application, and I have query params where I save some data about the application.

I'm using ui-sref no navigate to another state, but this removes the query params from the URL. Is there any way to change the state of the application without removing the query params?

1 Answer 1

3

There is an option {location : false} - check the doc:

go(to, params, options)

... Options object. The options are:

  • location - {boolean=true|string=} - If true will update the url in the location bar, if false will not. If string, must be "replace", which will update url and also replace last history record.
  • inherit - {boolean=true}, If true will inherit url parameters from current url.
  • relative - {object=$state.$current}, When transitioning with relative path (e.g '^'), defines which state to be relative from.
  • notify - {boolean=true}, If true will broadcast $stateChangeStart and $stateChangeSuccess events.
  • reload (v0.2.5) - {boolean=false}, If true will force transition even if the state or params have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd use this when you want to force a reload when everything is the same, including search params.

But I would rather keep such parameters as part of target state url:

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

3 Comments

Hey, thanks for the comment. But I do want to url to be replaced, but just just the path part, not the query params
As I said, there is solution "keep such parameters as part of target state"... so I would suggest to extend target state, and pass these params as well. That would be the native UI-Router solution... Does it help? It could even be driven by state inheritance, so these params are defined by parent and child just profit from it...
Thanks, I ended up passing the params inside the ui-sref (ui-sref="secondPage({param1: value1})") I just thought maybe there is an easier way just to leave the query params as they are.

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.