This is the nested route that i have created in ember.
App.Router.map(function(){
this.resource('makes', function(){
this.resource('model', {path: ':division_id'}, function(){
this.resource('zip', {path: ':model_id'});
});
});
this.resource('spec', {path: '/makes/:division_id/:model_id/:zipcode'});
});
In the ziproute when i log the params this is the output i'm getting.
Object {model_id: "ILX"}
But the url for zip route is like /makes/Acura/ILX. So i should be getting the both division_id and model_id.
I'm unable to get division_id in params.
Example app is done at : http://jsbin.com/jujene/36/edit
Not sure if this is exactly what you're going for. In your route, you can get the parent model using Route.modelFor
App.ModelRoute = Ember.Route.extend({
model: function(params){
console.log('model params', params);
return { id: params.division_id};
},
});
Since Model route has access to the params, you can set it on your model that way. This way the Model Route sets up a model.
Then, on your zip route:
App.ZipRoute = Ember.Route.extend({
model: function(params){
var m = this.modelFor('model');
console.log('division id', m.id);
console.log('zip params', params);
params.division_id = m.id;
return params;
}
});
See updated sample JSbin, which is a slightly cleaned up copy of yours.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With