AngularJS UI-Router 导航而不删除查询参数 [英] AngularJS UI-Router navigate without removing query params

查看:31
本文介绍了AngularJS UI-Router 导航而不删除查询参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 UI-Router 来管理我的应用程序的状态,并且我有查询参数,用于保存有关应用程序的一些数据.

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.

我使用 ui-sref 没有导航到另一个状态,但这会从 URL 中删除查询参数.有没有办法在不删除查询参数的情况下更改应用程序的状态?

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?

推荐答案

有一个选项 {location : false} - 检查文档:

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

...选项 对象.选项是:

... Options object. The options are:

  • location - {boolean=true|string=} - 如果为 true 将更新地址栏中的 url,如果为 false 则不会.如果是字符串,必须是替换",这将更新 url 并替换最后的历史记录.
  • inherit - {boolean=true},如果为true,将从当前url继承url参数.
  • relative - {object=$state.$current},当使用相对路径(例如'^')转换时,定义相对于哪个状态.
  • notify - {boolean=true},如果为 true 将广播 $stateChangeStart 和 $stateChangeSuccess 事件.
  • reload (v0.2.5) - {boolean=false},如果为 true,即使状态或参数没有改变,也会强制转换,也就是重新加载相同的状态.它与 reloadOnSearch 不同,因为当你想要在一切都相同时强制重新加载,包括搜索参数.
  • 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.

但我宁愿保留这些参数作为目标状态的一部分 url:

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

这篇关于AngularJS UI-Router 导航而不删除查询参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆