I have 2 component(comp1 and comp2) in main component that component2 has child component, I have tried to call a function in a component1 from child component of component2.
1 Answer
You can read this usefull article about sharing data between Angular Components.
You can share Data via ViewChild or Output() and EventEmitter from child to parent(comp2 child to comp2) and then share these data to the sibling comp 1. But i think the best way is to use a service where you can share data on unrelated Components
3 Comments
Mina Fardin
Thank you for your answer, but I want to call a function between siblings component not sharing data between them.
Tzimpo
@MinaFardin like sharing data you can use eventEmitter to call function from sibling component
Mina Fardin
I could not call directly function between child component and sibling component. and because of that first of all I have tried to call parent function of child component then have called function of main component and finally I could access to child function of main component. This will be clearer by drawing the shape but I could not share it.