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)" />

Explanation

The parent listens with event binding, and $event contains the emitted value. The older equivalent is @Output() changed = new EventEmitter<number>().

Further reading

Problem with a question

Angular · Junior · question 26

Test yourself

Take the Angular · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz