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

查看:77
本文介绍了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 对象.选项是:

... Options object. The options are:

  • location - {boolean=true|string=}-如果为true,则将更新位置栏中的URL;如果为false,则不会更新.如果为字符串,则必须为替换", 将会更新网址,并替换最后的历史记录记录.
  • inherit - {boolean=true},如果为true,则会从当前网址继承网址参数.
  • 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天全站免登陆