October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Angular Component Output Interop: Connect Outputs and Observables

Angular’s output interop helpers solve opposite tasks: expose an RxJS stream as a component output or adapt an Angular output into an Observable.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Angular provides two interop helpers for opposite directions: outputFromObservable() exposes an RxJS stream as a component or directive output, while outputToObservable() converts an Angular output into an RxJS Observable. For a new imperative event, use output(). These function-based APIs are intended for Angular v19 and later; check the documentation for your installed release before adopting them.

Choose the API by the direction of the event

Need Use What it does
Emit an event when component code decides output() Declares an Angular output that component code emits with .emit().
Expose an existing RxJS stream as an Angular output outputFromObservable(source$) Forwards values from an Observable to consumers of the component or directive output.
Use an Angular output in an RxJS pipeline outputToObservable(outputRef) Adapts an output to an RxJS Observable for operators and composition.
Listen to an output with a callback only OutputRef.subscribe() Subscribes directly, without adding an RxJS conversion when no pipeline is needed.

Angular documents output() as stable since v19.0. Its function-based output API is recommended for new projects, but the older @Output() and EventEmitter approach remains supported. See Angular’s component outputs guide and output() API reference.

Declare an output for imperative events

Use output() when the component itself determines when an event occurs. It returns an OutputEmitterRef, which exposes .emit(). Declare it as a class property initializer in a component or directive; Angular recognizes this initializer as an output declaration.

import { Component, output } from '@angular/core';

@Component({
  selector: 'app-save-button',
  template: '<button (click)="save()">Save</button>',
})
export class SaveButtonComponent {
  saved = output<string>();

  save() {
    this.saved.emit('done');
  }
}

A parent can listen with a template binding such as <app-save-button (saved)="handleSaved($event)" />. Angular also supports programmatic subscription to an output reference. Angular cleans up output subscriptions when it destroys the component.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Expose an Observable as an Angular output

Use outputFromObservable() when an RxJS Observable already represents the event stream and consumers should receive it through the component’s normal output interface. Declare the interop call as a property initializer in the component or directive.

import { Component, outputFromObservable } from '@angular/core';
import { fromEvent } from 'rxjs';

@Component({
  selector: 'app-pointer-tracker',
  template: '<div class="area">Move the pointer here</div>',
})
export class PointerTrackerComponent {
  private pointerMoves$ = fromEvent<PointerEvent>(window, 'pointermove');

  pointerMove = outputFromObservable(this.pointerMoves$);
}

The output forwards Observable values to output subscribers. Forwarding stops when the owning component or directive is destroyed. If the source completes, no further values are forwarded. Angular does not handle errors from the source Observable for you: arrange error handling in the stream or otherwise manage the error yourself. See Angular’s outputFromObservable() API reference.

Convert an Angular output to an Observable

Use outputToObservable() when you need to pass values from an Angular output through RxJS operators. The helper returns an Observable<T>.

import { Component, output, outputToObservable } from '@angular/core';
import { debounceTime } from 'rxjs';

@Component({
  selector: 'app-search-box',
  template: '<input (input)="queryChange.emit($any($event.target).value)">',
})
export class SearchBoxComponent {
  queryChange = output<string>();
  debouncedQuery$ = outputToObservable(this.queryChange).pipe(debounceTime(250));
}

This is useful when an output needs RxJS composition, such as filtering or combining streams. If the task is only to run a callback when the output emits, use OutputRef.subscribe() instead. Angular ties subscriptions made through the interop helper to the component or directive owner’s destruction. See the outputToObservable() API reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep or migrate legacy EventEmitter outputs

EventEmitter<T> is the decorator-era event mechanism and extends RxJS Subject<T>, adding .emit(). Existing code using @Output() and EventEmitter can continue to work; there is no need to convert a component solely because the function-based API is newer. For new declarations, Angular recommends output(). The Angular outputs guide describes both approaches.

To migrate eligible declarations, run the Angular CLI schematic:

ng generate @angular/core:output-migration

The schematic can update eligible output members and imports, change certain .next() calls to .emit(), and remove .complete() calls. It does not cover every code shape.

  • It may skip output usages involving .pipe() outside recognized test files. For test files, its documented recognition looks for imports containing jasmine or catalyst; some piped test usages may be rewritten to outputToObservable(...).
  • --path limits which files are changed. --analysis-dir limits reference analysis; if references lie outside that directory, they can be missed and the migration may break the build.
  • Review the generated diff and run the project’s tests and build after migration.

See Angular’s output migration guide for the schematic’s behavior and options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Output names and template behavior

Angular outputs are custom component events, not bubbling DOM events. A listener on an ancestor element will not receive an output emitted by a nested component unless the component hierarchy explicitly passes it along. Output names are case-sensitive.

  • An alias changes the public name used in a template, not the TypeScript property name.
  • Outputs inherited from a base component are also available on child classes.
  • Use camelCase, avoid an on prefix, and avoid names that collide with native DOM events.

These naming and binding rules are described in the Angular component outputs guide.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.