在Ember 2.x中路由之间传递参数 [英] Passing parameters between routes in Ember 2.x

查看:239
本文介绍了在Ember 2.x中路由之间传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从一个路由到另一个路由,我想传递一些数据(特别是数组)。如何可能?

While going from one route to another, I want to pass some data (especcially arrays). How is it possible?

为什么我们不能使用数组的查询参数?

Why can't we use query-params with arrays?

是否

注意:
我知道有一些旧的问题,几乎是一样的有这个问题。但他们选择的答案不再适用于Ember 2.x.这些问题有: 1 2

推荐答案

我不知道如果queryparams不能使用数组,因为我只使用单个ids,但它会不是一个很好的解决方案,即使它有效,你可以通过参数发送多少限制,你不应该打扰任何用户的数据。

I´m not sure if queryparams won´t work with arrays as I only used it with single ids, but it would not be a good solutions even if it worked, there´s a limit on how much you can send by parameters and you should not bother any user with your data.


  1. 只需创建一个模型来保存您的数据以供本地使用,因此您可以简单地使用ember store

  1. Just create a model to save your data for local use, so you can simply use the ember store

使用服务必须在每个需要使用数据的控制器上注入

Use a service you´ll have to inject in every controller you want to use your data

我更喜欢模型/商店变体你可以观察并遵循正常的流程,如果有人必须维护你的代码,那也是很好的。

I would prefer the model/store variant so you´ll be able to observe and just follow the normal flow which is also good if someone else has to maintain your code.

这篇关于在Ember 2.x中路由之间传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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