如何在afterModel钩子中替换路由/控制器的模型。
here is a jsbin of things I've tried
afterModel: function(model){
model = { id: "noob", name: "Bob" };
this.currentModel = { id: "noob", name: "Bob" };
//this.set('controller.content', { id: "noob", name: "Bob" });
//this.set('controller.model', { id: "noob", name: "Bob" });
this.set('currentModel', { id: "noob", name: "Bob" });
return new Ember.RSVP.Promise(function(resolve) { resolve({ id: "noob", name: "Bob" });
});
答案 0 :(得分:1)
您无法更改model
挂钩中Ember.Route#setupController()
的{{1}},因为
使用当前路径的控制器和模型钩子提供的模型调用此方法。 (Ember Documenation over here)
为什么要在模型解决后更改模型?