modelFor (name) Objectpublic
Returns the resolved model of a parent (or any ancestor) route in a route hierarchy. During a transition, all routes must resolve a model object, and if a route needs access to a parent route's model in order to resolve a model (or just reuse the model from a parent), it can call this.modelFor(theNameOfParentRoute) to retrieve it. If the ancestor route's model was a promise, its resolved result is returned.
Example
App.Router.map(function() {
this.route('post', { path: '/post/:post_id' }, function() {
this.route('comments', { resetNamespace: true });
});
});
App.CommentsRoute = Ember.Route.extend({
afterModel: function() {
this.set('post', this.modelFor('post'));
}
});
Parameters:
-
name
String - the name of the route
Returns:
-
Object - the model object
Please login to continue.