我正在使用 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);
}
}
});
我该如何解决?
test
从技术上讲,它不是一种方法,而是一种动作或事件。使用send
方法改为:
this.get('controllers.account_info').send('test', arg1, arg2);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)