Ember:绑定控制器属性查询参数 [英] Ember: binding controller properties to query parameters

查看:80
本文介绍了Ember:绑定控制器属性查询参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道ember应该有一些内置的控制器绑定属性和查询参数。文件状态(指先前的示例):

I know ember is supposed to have some built-in binding of controller properties and query params. Docs state (referring to a previous example):

once the articles route has been entered, any changes 
to the category query param in the URL will update the 
category property on controller:articles, and vice versa.

反之亦然表示如果对其中一个控制器属性进行更改,也将反映在URL上的QP中。也许我错误地解释了这一点。但是如果我的解释是正确的(可能不是这样),这不是真正的发生。

I take "vice versa" to mean that if there's a change to one of the controller properties, it would also be reflected in the QPs on the URL. perhaps I am mis-interpreting that. But if my interpretation is correct (it's probably not), it's not what's actually happening.

我把一个旋转演示

有没有办法绑定QP对控制器的属性,以便

Is there a way to bind the QPs on the url to the controller properties so that

a)控制器属性更新如果url QP更新

a) the controller properties update if the url QPs update

b)如果控制器属性更新,位置栏中的QP将更新

b) the QPs in the location bar update if the controller properties update

/ p>

Any help appreciated

推荐答案

deleteStuff 中,您可以将其设置为默认值,将照顾更新路线,如果其默认值不会显示在URL中。所以要使其工作,包括路线/ search.js文件中的 queryParams:{q:{refreshModel:true}}

In deleteStuff, you can just set it to default value then it will take care of refreshing route and it will not be shown in URL if its default value. So to make it work include queryParams: { q:{ refreshModel: true }} in routes/search.js file.

请参阅这个旋转,它将更新参数 q ,它将在URL中更新,并将刷新路由。如果q设置为默认值,那么它不会显示在URL中。

Refer this twiddle it will update params q and it will be updated in URL and it will refresh route. and if q is set to default value then it will not be shown in URL.

这篇关于Ember:绑定控制器属性查询参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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