在下面的“约会”路线中,我可以伸手并获取父“日”的模型
App.Router.map(function(match) {
this.resource("day", { path: "/day/:day" }, function() {
this.resource("appointments", { path: "/appointments" }, function() {
this.route("new", { path: "/:appointment_start/new" });
this.route("edit", { path: "/:appointment_id/edit" });
});
});
});
但是当我深入到新的或编辑的路线中时,我怎样才能(从动作处理程序中)伸手去抓住父“日”模型,就像我在路线中所做的那样?
App.AppointmentsEditController = Ember.Controller.extend({
actions: {
updateAppointment: function(appointment) {
var day = this.get('??');
}
}
});
更新
最终的控制器代码现在看起来像这样
App.AppointmentsEditController = Ember.Controller.extend({
needs: 'day',
actions: {
updateAppointment: function(appointment) {
var day = this.get('controllers.day');
}
}
});