Route#afterModel()

afterModel (resolvedModel, transition) Promisepublic

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

This hook is called after this route's model has resolved. It follows identical async/promise semantics to beforeModel but is provided the route's resolved model in addition to the transition, and is therefore suited to performing logic that can only take place after the model has already resolved.

App.PostsRoute = Ember.Route.extend({
  afterModel: function(posts, transition) {
    if (posts.get('length') === 1) {
      this.transitionTo('post.show', posts.get('firstObject'));
    }
  }
});

Refer to documentation for beforeModel for a description of transition-pausing semantics when a promise is returned from this hook.

Parameters:

resolvedModel Object
the value returned from `model`, or its resolved value if it was a promise
transition Transition

Returns:

Promise
if the value returned from this hook is a promise, the transition will pause until the transition resolves. Otherwise, non-promise return values are not utilized in any way.
doc_EmberJs
2016-11-30 16:53:04
Comments
Leave a Comment

Please login to continue.