@johnnyicon wrote:
I’m confused as to how nested routes and dynamic segments work with Ember.
Below is how I’ve defined a series of nested routes for a House. I’ve been following the pattern for defining routes using Dynamic Models guide found here: https://guides.emberjs.com/v2.15.0/routing/specifying-a-routes-model/#toc_dynamic-models
this.route('houses'); this.route('house', {path: 'houses/:house_id'}, function() { this.route('show', {path: 'houses/:house_id/show'},); this.route('level-1', function() { this.route('master-bedroom', {path: 'houses/:house_id/level-1/master-bedroom'}); this.route('bathroom', {path: 'houses/:house_id/level-1/bathroom'}); this.route('patio', {path: 'houses/:house_id/level-1/patio'}); }); });
I don’t understand why I have to keep specifying the entire path in order to get access to the
:house_id
dynamic segment. If I don’t specify the entire path with the dynamic segment:house_id
, then trying to access the:house_id
in theparams
object in themodel()
hook returnsundefined
.Is there a better way to do this?
Posts: 3
Participants: 3