Route#modelFor()

modelFor (name) Objectpublic

Defined in packages/ember-routing/lib/system/route.js:1738

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
doc_EmberJs
2016-11-30 16:53:10
Comments
Leave a Comment

Please login to continue.