gpt4 book ai didi

ember.js - 在另一个 Controller Ember 中调用 Controller 方法

转载 作者:行者123 更新时间:2023-12-04 09:40:23 30 4
gpt4 key购买 nike

我正在使用 Ember 的 Need Api 在另一个 Controller 中调用 Controller 的方法。我能够获取 Controller 的实例,但是当我调用它的方法时,它会返回此错误 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


}
}
});

这是我想调用其功能的 Controller
Cards.AccountInfoController = Ember.Controller.extend({


actions:{

test: function(){

alert(1);
}

}

});

我该如何解决?

最佳答案

test技术上不是方法,而是 Action 或事件。使用 send方法代替:

this.get('controllers.account_info').send('test', arg1, arg2);

关于ember.js - 在另一个 Controller Ember 中调用 Controller 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22861316/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com