0

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?

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.

remino
  • 324
  • 2
  • 17

1 Answers1

0

you can access the parameters in the route and sending them to the controller by:

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... );
}
mihai
  • 4,184
  • 3
  • 26
  • 27