在Ember.Route上使用setupController时,是否需要在控制器上设置模型?

cav*_*neb 4 ember.js

我对Ember.Route模型与setupController有一些混淆.我在这里有一个示例应用程序:

http://jsbin.com/ihakop/5/edit

我想知道为什么我需要添加以下内容(请参阅内联注释)

App.AppsShowRoute = Ember.Route.extend({
  model: function(params) {
    return App.LtiApp.find(params.id);
  },

  setupController: function(controller, model) {
    controller.set('reviews', App.Review.find());

    // Why is this line needed? Shouldn't it have the model
    // already on the controller?
    controller.set('model', model);
  }
});
Run Code Online (Sandbox Code Playgroud)

模型不应该在控制器上吗?

mav*_*ein 8

这是一个很好的问题.RC4引入了此行为.看一下这篇博客文章的解释.Ember家伙的建议是添加一个电话_super():

App.AppsShowRoute = Ember.Route.extend({
  model: function(params) {
    return App.LtiApp.find(params.id);
  },

  setupController: function(controller, model) {
     this._super(controller, model);
     controller.set('reviews', App.Review.find());
  }
});
Run Code Online (Sandbox Code Playgroud)