[英]How do I get an object out of query params in Ember 2?
In Ember 2, for a URL with a query string of ?q[a]=1&q[b]=2
, how do I get those params in the controller? 在Ember 2中,对于查询字符串为
?q[a]=1&q[b]=2
的URL,如何在控制器中获取这些参数?
I'm able to get a single string ( q=foo
) and an array ( q[]=1&q[]=2
), but I'm unable to get an object like mentioned above. 我可以得到一个字符串(
q=foo
)和一个数组( q[]=1&q[]=2
),但是我无法获得上述对象。
you can access the parameters in the route
and sending them to the controller
by: 您可以通过以下方式访问
route
的参数并将其发送到controller
:
setupController(controller, model, transition) {
this._super(...arguments);
// transition.params contains params in the url
// this.get('router.url') contains all query params
// your method in the controller to handle the params
controller.setQueryParams( ...your params... );
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.