NG.I · Angular 22 practice question
A developer is building a reusable component, `VolumeControl`, that emits a signal when the volume changes. They want the consuming component's template to listen for an event named `volumeUpdated` instead of the default `volumeChanged` name. How should they configure the output property in the component's TypeScript file?
export class VolumeControl {
volumeChanged = output({alias: 'volumeUpdated'});
}
Check answer and explanation
Correct answer: volumeChanged = output({alias: 'volumeUpdated'});
Explanation
The proper configuration involves utilizing the `output` function with an object literal that specifies the `alias` property to rename the event being emitted within the template.
Common trap
Passing the alias as a simple string to the `output` function is syntactically flawed for customizing the output name. Furthermore, using the property name `newAlias` instead of `alias` results in an incorrect implementation.
Source: Angular docs: Custom events with outputs — Customizing output names
Checked against the cited text on 2026-11-25.