adspace
How can we call child component controller method from the parent component controller method? : salesforce lightning component
Answer Posted / Sarvesh Siddharth
To call a child component's controller method within the parent component's controller, you can use the `$A` utility to find and invoke the desired method. Here's an example:
```javascript
// In Parent Component Controller
{!c.init}
function init() {
var childComponent = this.find('childComp'); // Assuming the child component's aura:id is 'childComp'
$A.enqueueAction(actionFunction);
function actionFunction() {
childComponent.callChildMethod(); // Calling child component's method
}
}
```
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers