# In Angular 7, how do I access the component that emitted an event?

Let’s say I have a component with a custom event:

child.component.html

<button (click)="buttonClicked()">Test</button>


child.component.ts

@Component({
selector: 'my-child',
templateUrl: './child.component.html'
})
export class ChildComponent {
@Output() myEvent = new EventEmitter();

public buttonClicked() {
this.myEvent.emit();
}
}


Then I have another component that contains multiple instances of the first component.

parent.component.html

<my-child id="my-child-component-1" (myEvent)="myEventOccured()" />
<my-child id="my-child-component-2" (myEvent)="myEventOccured()" />


parent.component.ts

@Component({
selector: 'my-parent',
templateUrl: './parent.component.html'
})
export class ParentComponent {
public myEventOccured() {
//HERE I WANT I REFERENCE TO THE COMPONENT EMITTING THE EVENT.
}
}


In the function that handles the custom event of the child components (myEventOccured()), I want to access the component that emitted the event. How do I do that?

I’m thinking maybe I should send the emitting component as an argument to the function handling the event (myEventOccured()), but I don’t know how.

Source: New feed
Source Url In Angular 7, how do I access the component that emitted an event?