Skip to content Skip to sidebar Skip to footer

How To Pass Model In Nested Routes - Emberjs

I have some nested routes. App.Router.map(function() { this.route('dashboard', { path: '/dashboard' }); this.resource('customers', { path: '/customers' },function(){ this.r

Solution 1:

You need to specify a route for customer contact (as well for customer). The reason it works initially is because the link-to is passing the model to the route, so it can skip the non-existent model hook. But when you refresh the page, or hit the contact route, which has no dynamic segment, you need to tell ember that you want to use a model. There is a beta feature that allows all the routes under a resource to use the resource if they don't have another resource defined, but that's still a feature, and isn't yet gold.

App.CustomerRoute = Ember.Route.extend({
  model: function(param){
    returnthis.store.find('customer', param.customer_id);
  }
});

App.CustomerContactRoute = Ember.Route.extend({
  model: function(){
    returnthis.modelFor('customer');
  }
});

http://jsbin.com/EveQOke/110/edit

Post a Comment for "How To Pass Model In Nested Routes - Emberjs"