我在视图中,我想将动作发送到与我所在的视图不同的控制器或路由器。我该怎么做?
App.FormView = Ember.View.extend ({
actions: {
clicked: function() {
context = this.get("context");
App.OtherViewController.send("clicked", context); //this doesn't work
// this.get("controller").send("clicked", context); // this sends to the current controller
}
}
});
答案 0 :(得分:1)
如果FormController
needs
某些ThingController
,您可以FormView
通过this.get('controller.controllers.thing')
进入FormController
。从this.get('controllers.thing')
内部您可以使用App.FormController = Ember.ObjectController.extend({
needs : ['thing']
});
App.FormView = Ember.View.extend ({
actions: {
clicked: function() {
context = this.get("context");
// this sends to the ThingController
this.get("controller.controllers.thing").send("clicked", context);
}
}
});
。
{{1}}