Skip to main content

What is EventEmitter?

EventEmitter in Angular is a class used to create events in components so that a child component can send data to the parent through @Output().

How it works:

  1. An instance of EventEmitter is created in the child component.
  2. The .emit(value) method sends data or a notification about the event.
  3. The parent component subscribes to this event through (eventName) and receives the passed data.

Example:

typescript
@Output() clicked = new EventEmitter<string>(); someMethod() { this.clicked.emit('Data sent to the parent'); }

Conclusion: EventEmitter is a mechanism for communication from a child component to its parent, implementing the passing of events and data.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.