Is is possible to inspect a child route/the url of an app from a parent route? My parent routes contain lists of items and I want to transition to/select the first item in the list automatically if an item isn’t already selected. As an example:
Given URL /parent/10/
with the following router and routes:
App.Router.map(function () {
this.resource('parent', function () {
this.route('detail', { path: ':item_id' });
});
});
App.ParentRoute = Ember.Route.extend({
model: function () {
return this.store.find('item');
},
setupController: function (controller, model) {
controller.set('model', model);
// somehow set this to the selectedObject (/10 in the above url) if present
var selected = controller.get('sortedContent').get('firstObject');
this.transitionTo('parent.detail', selected);
}
});
App.ParentDetailRoute = Ember.Route.extend({
model: function(params) {
return this.get('item', params.item_id);
}
})
My problem right now is /parent/10/
and /parent/
both end up at /parent/1/
because of the way selected
is currently set. Is there a way to see if the URL has a slug attached and transition to that if present?