3

I have a parent component and a child component. In the child component on some action, I need to call a function in the parent component. For this I have used Event Emitters. The details of which are as below:

Parent html

            <app-child-component
                [param 1] = "val1"
                [param 2] = "val2"
                [param 3] = "val3"
                [param 4] = "val4"
                (updateCounts) = "updateCount($event)"
                (myClose)="close()">
            </app-child-component>

Parent component.ts

updateCount(event){
  console.log('Event=');
  console.log(event);
}

close(){
  console.log('close() called');
}

Child component.ts

@Output() updateCounts = new EventEmitter<any>();
@Output() myClose: EventEmitter<any> = new EventEmitter<any>();

.....
someFunction(){
  this.updateCounts.emit({"val1": "TEST"});
}
someFunction123(){
  this.myClose.emit({"val1": "TEST"});
}

The myClose event works as expected but updateCounts event doesn't.

Foramkumar Parekh
  • 421
  • 1
  • 6
  • 26

0 Answers0