简体   繁体   中英

AngularJS UI-Router navigate without removing query params

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?

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 (eg '^'), 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 :

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM