AngularJS UI-Router navigate without removing quer

2019-07-15 12:16发布

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条回答
叼着烟拽天下
2楼-- · 2019-07-15 12:43

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:

查看更多
登录 后发表回答