Recently, I've been struggling to transfer data between components in my Angular project. Despite trying numerous online examples, none have seemed to work for me.
Most of the tutorials I came across suggest using @Input and @Output as the ideal way to pass data between components in Angular.
My current component structure is as follows:
I include ComponentA in the HTML of ComponentC like this:
<app-componentA</app-componentA>
ComponentB is called via modalController.
https://i.sstatic.net/By6jF.png
In my code, I pass data generated in ComponentB to ComponentC using the following method:
// componentB.ts
dimiss(filters?: any) {
this.modalController.dismiss(filters);
}
And receive it in ComponentC like this:
// componentC.ts
const filters = await modal.onDidDismiss();
this.Myfilters = filters ;
Now, the question arises - how can I pass the data from ComponentB to ComponentA?