output()
Declares a component output that emits events to the parent.
Syntax
output<T>(options?): OutputEmitterRef<T> Parameters
| Name | Type | Required | Description |
|---|---|---|---|
options | object | No | Supports an alias for the public event name. |
Returns
OutputEmitterRef<T> — An object with an emit(value) method.
Examples
import { Component, output } from '@angular/core';
@Component({
selector: 'app-search',
standalone: true,
template: `<input (input)="onInput($any($event.target).value)" />`,
})
export class SearchComponent {
query = output<string>();
onInput(value: string) {
this.query.emit(value);
}
}
// parent template
// <app-search (query)="handle($event)" />
Notes
output() is the signal-era replacement for @Output() with EventEmitter. Call
emit() to send a value to listeners bound in the parent template. Use the
alias option to publish the event under a different name. There is no need to
unsubscribe; Angular handles teardown.