mardi 15 novembre 2022

Ember invoke a component function from another component in same engine parent

my requirement is to use component actions from another component.Need to know whether it is possible to use data-down for this case.

Say,

I'm trying to invoke first-component from here engine/addon/templates/application.hbs like below

engine/addon/templates/application.hbs

    
    <FirstComponent action=actionFromSecondCompo/>
    

From this FirstComponent i want to invoke, second-component function handled in

engine/addon/components/SecondComponent.js

actionFromSecondCompo(){
 console.log("Print Invoked secondcomponent");
}

Note: Both components are in same engine parent
i've tried to use **extend** the firstComponent in secomdCompo js like below.

>>engine/addon/components/SecondComponent.js

import FirstComponent from 'engine/components/FirstComponent'; export default FirstComponent.extend({


But issue here is, its invoking willDestroyElement() function from FirstComponent.Hence i don't need the changes handled inside this destroy function.



Aucun commentaire:

Enregistrer un commentaire