我需要从 MyController
的 handleUpdate
方法触发我的 Summary
Controller 中的操作方法。
我的 Controller
:
MyController = MyController.extend({
needs: ['application', 'Summary'],
handleUpdate: function() {
var controller = this;
Ember.run.later(function() {
...
...
}.bind(this), 100);
}.observes('isUpdating')
}
更新
Controller :
SummaryController.reopen({
actions: {
update: function(source, callback) {
...
...
}
}
});
谢谢
最佳答案
获取 Controller 实例,然后使用方法 send
触发操作。
MyController = MyController.extend({
needs: ['application', 'summary'],
handleUpdate: function() {
var controller = this,
summaryController = this.get('controllers.summary');
summaryController.send('update');
Ember.run.later(function() {
...
...
}.bind(this), 100);
}.observes('isUpdating')
}
关于javascript - 从另一个 Controller 触发 Controller 的 "actions",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21681147/