在Ember 2中,对于查询字符串为?q[a]=1&q[b]=2
的URL,如何在控制器中获取这些参数?
我能够获得一个字符串(q=foo
)和一个数组(q[]=1&q[]=2
),但是我无法获得上面提到的对象。
答案 0 :(得分:0)
您可以访问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... );
}