Dynamic segment from parent routing resource not available to nested route by design?

As you can see here Ember Latest - JSFiddle - Code Playground I was expecting the dynamic segment from parent routing resource to be available for the nested routes and resources.

It was not.

So I had to retrieve the model by using this.modelFor(‘parent_resource’) in the current route’s model hook.

It seems to me that it would be better, if it was available in params for the current route. It would make more sense (to me) and the routes wouldn’t have to depend on others model hooks.

It would also be easier to work with multiple dynamic segments from parent routes and current route, if they were all available to the current route’s model hook (in the params argument).


A nested route is always going to have by default a different model and controller than any other route, including a parent route. If, in the nested child route, you want access to the parent route’s model, you’ll have to use modelFor, as described by this lightly updated jsFiddle.

But the OP isn’t asking for the parent model, but the value of the dynamic segment of the parent route (which is part of the complete URL of the child). It still seems to me that this would make sense, and while I’ve seen plenty of people say “just use modelFor,” I haven’t heard an explanation for why the params of a child model hook don’t contain all of the dynamic segments that are currently in play. Is the reason documented somewhere? Is there a technical explanation for why it doesn’t work this way?

This doesn’t explain why Ember behaves this way, but I believe that you can access the other params in the transition.params object in beforeModel, or alternatively, there’s also this.paramsFor.

Edit: Oh oops, just noticed that this post is from awhile ago.