user1795109
user1795109

Reputation: 716

Access controller's function from other controller

I have two controllers as follow.

App.CreditIndexController = Ember.ArrayController.extend({
    viewAll: function(){
        //Some code
    }
})


App.CreditVoucherController = Ember.ArrayController.extend({
    needs: ['creditIndex'],
    viewAllVoucher: function(){
        this.get('controller.controllers.creditIndex').viewAll();
    }
})

I was trying to access viewAll function from CreditVoucherController. But it didn't worked. What is the way do it.

Upvotes: 0

Views: 47

Answers (1)

mavilein
mavilein

Reputation: 11668

You have a to access another controller via the controllers property:

App.CreditVoucherController = Ember.ArrayController.extend({
    needs: ['creditIndex'],
    viewAllVoucher: function(){
        this.get('controllers.creditIndex').viewAll();
    }
});

Upvotes: 1

Related Questions