Services, DI & Communication
Angular Output and EventEmitter
@Output exposes a custom event a child can emit, and the parent listens with event binding. Together with @Input it forms the standard parent-child communication pair.
What is Output and EventEmitter in Angular?
@Output exposes a custom event a child can emit, and the parent listens with event binding. Together with @Input it forms the standard parent-child communication pair.
Output and EventEmitter example
export class JobCardComponent {
@Input({ required: true }) job!: Job;
@Output() applied = new EventEmitter<string>();
@Output() saved = new EventEmitter<{ id: string; saved: boolean }>();
onApply(): void {
this.applied.emit(this.job.id);
}
}Listening in the parent
<app-job-card [job]="job" (applied)="handleApply($event)" (saved)="handleSave($event)" />$event carries whatever the child passed to emit — here a job id string, or an object for the saved event.
Key points to remember
- Name outputs as things that happened (applied, saved), not as commands.
- The generic parameter types the payload, so $event is typed in the parent.
- An output named xChange combined with an @Input x enables [(x)] two-way binding.
Common mistakes with Output and EventEmitter
- Emitting inside ngOnInit before the parent has bound its listener.
- Passing a callback down as an @Input instead of using an output — it works but fights the framework.
Angular Output and EventEmitter— Interview Questions & FAQs
How do child and parent components communicate in Angular?+
Parent to child with @Input property bindings; child to parent with @Output events. For components that are not directly related, use a shared service with a Subject or a signal.
