Routes with same query params


If I have a route and sub-route (eg. /reports/:report_id and /reports/:report_id/charts/:chart_id) and they have both the same query parameters (eg. “start_date” & “end_date”), should I define the query parameters in both routes, or should I only define the params in the parent route, and the sub-route just take the query parameters from its parent route (via this.controllerFor(), for example)? Is there a definitive Ember way, or are both options valid with their own pros/cons?


Only the first option will work - params have to be uniquely named for query params of controllers that are active at the same time.

Using inject.controller to share the params with subcontrollers is usually the best solution


Thanks! I just found out the hard way that I couldn’t have params of the same name. I had no idea I could inject other controllers. What I did end up doing was creating a service, where I store my param in the service and access it from other controllers. If injecting other controllers ends up being cleaner, I may opt for that approach.

UPDATE: Using Ember.inject.controller() indeed is much cleaner and works as expected!