How to call child controller function from parent component if same component is getting called 4 times in parent component?
TechnicalSenior Salesforce DeveloperSalesforce DeveloperSalesforce EngineerTo call a child controller function from a parent component, I would use event dispatching. Each child component can fire an event that the parent listens for. When the parent detects this event, it can then invoke the desired function on the child component.
Specifically, I would:
- Define a custom event in the child component.
- Dispatch this event from the child when needed.
- Handle the event in the parent component and call the child function using component.find().
This approach maintains a clear separation of concerns while allowing communication between components.