Explain @Output and EventEmitter.
Skip to solutionKEEP THE
easyFrontend
How do child components emit events to parents?
362 views
01
Understand the problem
outputeventemitter
02
Attempt it yourself
Sketch your approach before reading the solution — that's what interviews test.
Nudge consolestandby
Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.
03
Study the solution
A child declares @Output() change = new EventEmitter<T>() and calls this.change.emit(value). The parent binds (change)="handler($event)". Modern Angular also offers the output() function as a signals-based alternative.
Solution ready — 2 min read
Classified // press E to declassify
04
Read the code
Child @Output → parent handler
import { Component, Output, EventEmitter, Input } from '@angular/core';
@Component({
selector: 'app-likes',
standalone: true,
template: '<button (click)="like()">👍 {{ count }}</button>',
})
export class LikesComponent {
@Input() count = 0;
@Output() liked = new EventEmitter<number>(); // event channel up
like() { this.liked.emit(++this.count); }
}
// Parent: <app-likes [count]="0" (liked)="onLiked($event)"></app-likes>05
Join the discussion
Discussion (0)
Sign in to join the discussion.
No responses yet. Be the first to share what you think.
Transmission complete // awaiting log
KEEP THE
STREAK ALIVE.
Dossier 9 of 121 decoded in the Angular track. One more won't hurt.