Angular · Junior · Question 26 of 75
How does a child component notify its parent about an event?
export class Counter {
changed = output<number>();
inc() { this.changed.emit(1); }
}
// parent: <app-counter (changed)="onChanged($event)" />- ✓Correct answer: With an output declared by
output()and calling.emit(value) - 2By modifying the parent's input directly
- 3By dispatching a DOM
CustomEventonly
Explanation
The parent listens with event binding, and $event contains the emitted value. The older equivalent is @Output() changed = new EventEmitter<number>().