lundi 31 octobre 2022

emberjs, how to bind method from controller to service?

I have big emberjs application and I need to start using ember service a little bit more. so I have a method in my controller that I want it to be available as a service in all the modals, and components where I inject the service.

but its not working, and with no error... si is this a good way to do this? why its not wotking?

so my method in the controller is:

openModalPrices () {
        //method in controller
    },

the service has another method:

openModalPricesFromService () {
        //method in service
    },

and in my INIT in the Controller I am binding like this:

init: function() {
   this._super(...arguments);
   this.get('priceService').openModalPricesFromService(this.openModalPrices.bind(this));
}



Aucun commentaire:

Enregistrer un commentaire