Calling a controllers method in another controller Ember

I am using Ember’s Need Api to call a method of a controller in another controller. I am able to get the instance of the controller but when I am calling it method it returns me this error
TypeError: Object [object Object] has no method. This is how I am calling it:

Cards.CardsIndexController = Ember.Controller.extend({
needs: 'account_info',
 actions: {
           console.log(this.get('controllers.account_info').test()); // error here


This is the controller whose function I want to call

Cards.AccountInfoController = Ember.Controller.extend({
    test: function(){

How can I solve it?

You should just send a message to another controller:


If you want to Set paramerters use this

this.get(‘controllers.account_info’).send(‘test’, param1, param2);

1 Like