例如,我有一个像这样的控制器:
App.theController = Ember.ArrayController.extend({
methodA:funtcion() {},
actions: {
methodB:function(){},
methodC:function(){}
}
});
Run Code Online (Sandbox Code Playgroud)
我的问题是:
int*_*xel 45
您必须使用this.send([methodName])才能正确调用您的方法:
var App = Ember.Application.create({
ready: function() {
console.log('App ready');
var theController = App.theController.create();
theController.send('methodC');
}
});
App.theController = Ember.ArrayController.extend({
methodA:function(){
//How can methodA calling methodB
this.send('methodB');
console.log('methodA called');
},
actions:{
methodB:function(){
//How can methodB calling methodC
this.send('methodC');
console.log('methodB called');
},
methodC:function(){
console.log('methodC called');
}
}
});
Run Code Online (Sandbox Code Playgroud)
这里有一个简单的jsbin作为游乐场.
希望能帮助到你.
| 归档时间: |
|
| 查看次数: |
20987 次 |
| 最近记录: |