使用 Ui-Router 的 ui-sref 来设置查询参数 [英] Use Ui-Router's ui-sref Just to Set Query Params

查看:29
本文介绍了使用 Ui-Router 的 ui-sref 来设置查询参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下链接.

<a ui-sref="...">Clicking this adds ?test=true to the query params.</a>

有没有一种方法可以使用 ui-sref 属性来更改查询参数,而无需重新加载页面或定向到另一个函数?

Is there a way to use the ui-sref attribute to just change query params without reloading the page or directing to another function?

推荐答案

您应该能够通过传递带有状态的参数来实现.

You should be able to do it by passing the arguments with the state.

尝试:-

<a ui-sref="yourStateName({test:true})">Clicking this adds ?test=true to the query params.</a>

用法:

ui-sref='stateName' - 导航到状态,无参数.'stateName' 可以是任何有效的绝对或相对状态,遵循与 $state.go() 相同的语法规则

ui-sref='stateName' - Navigate to state, no params. 'stateName' can be any valid absolute or relative state, following the same syntax rules as $state.go()

ui-sref='stateName({param: value, param: value})' - 使用参数导航到状态.

ui-sref='stateName({param: value, param: value})' - Navigate to state, with params.

这篇关于使用 Ui-Router 的 ui-sref 来设置查询参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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