我正在使用Ember的Need Api来调用另一个控制器中的方法。我能够获得该控制器的实例,但是当我调用它的方法时,会返回这个错误:TypeError: Object [object Object] has no method.
这是我如何调用它的:
Cards.CardsIndexController = Ember.Controller.extend({
needs: 'account_info',
actions: {
accountInfoStart:function(){
console.log(this.get('controllers.account_info').test()); // error here
}
}
});
这是我想要调用的控制器函数
Cards.AccountInfoController = Ember.Controller.extend({
actions:{
test: function(){
alert(1);
}
}
});
我该如何解决这个问题?