采用了棱角分明的UI设置路由器的网址查询参数没有状态变化 [英] Set URL query parameters without state change using Angular ui-router

查看:131
本文介绍了采用了棱角分明的UI设置路由器的网址查询参数没有状态变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该如何使用AngularJSUI路由器维护状态刷新页面时更新地址栏中的URL与不断变化的查询参数?

How should I update the address bar URL with a changing query parameter using AngularJS' ui-router to maintain state when refreshing the page?

目前,我使用 $ state.transitionTo('搜索',{Q:更​​新的搜索词'})当输入的变化,但问题是,这重新加载控制器,重绘窗口,失去任何文本输入焦点。

Currently, I am using $state.transitionTo('search', {q: 'updated search term'}) whenever input changes, but the problem is that this reloads the controller, redraws the window and loses any text input focus.

有没有一种方法来更新stateParams并实现同步到窗口URL?

Is there a way to update stateParams and sync it to the window URL?

推荐答案

我是有.transitionTo麻烦,直到我更新到 UI路由器 0.2.14。 0.2.14适当改变地址栏(无需重新加载控制器)使用这样的电话:

I was having trouble with .transitionTo until I updated to ui-router 0.2.14. 0.2.14 properly changes the location bar (without reloading the controller) using a call like this:

$state.transitionTo('search', {q: 'updated search term'}, { notify: false });

这篇关于采用了棱角分明的UI设置路由器的网址查询参数没有状态变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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