2014-10-01 38 views

回答

3

Working JSBin

當您使用掛鉤,這樣的如setupControllerrenderTemplate,您正在阻止Ember處理默認情況。對默認方法的調用:

App.IndexRoute = Ember.Route.extend({ 
    model: function() { 
    return ['red', 'yellow', 'blue']; 
    }, 
    setupController: function(controller, model) { 
    this._super(controller, model); 
    } 
}); 

從灰燼源評論:

這種方法被稱爲與控制器當前路線和 由model鉤提供的 模型。

默認情況下,setupController掛鉤將model屬性 控制器設置爲model。如果你在你的路由中實現了setupController掛鉤,它將會阻止這個默認行爲 。如果你想實現你的setupController功能時保留該行爲 ,請確保調用 _super