Angular Tutorial 0/55 lessons ~6 min read Lesson 42
Angular Modern output() API
The output() function replaces many @Output() EventEmitter declarations with a typed, tree-shakeable output signal-style API.
Course progress0%
Focus
5 guided sections
Practice signal
Examples included
Career prep
Interview Q&A included
Introduction
The output() function replaces many @Output() EventEmitter declarations with a typed, tree-shakeable output signal-style API.
Purpose of this lesson
You will declare outputs, emit events, and bind them with event bindings.
Informative example
Emit enrollment events:
typescript
import { Component, input, output } from "@angular/core";@Component({selector: "tlp-enroll-button",template: `<button type="button" (click)="enroll.emit(courseId())">Enroll</button>`,})export class EnrollButtonComponent {courseId = input.required<string>();enroll = output<string>();}// Parent:// <tlp-enroll-button courseId="angular" (enroll)="onEnroll($event)" />
Best practices
- Prefer
output<T>()over newEventEmitterfields in greenfield components. - Name outputs as verbs/events (
enroll,saved), notonEnroll.
Advanced interview questions
Interview Prep
Practice concise answers, then expand each card for the explanation.
1BeginnerQuestionDo output() and EventEmitter both work?+
Answer
Yes. output() is the modern function-based API. EventEmitter via @Output remains supported for existing code.
Ready to mark this lesson complete?Track your journey across the entire course.