NG.I · Angular 22 practice question
A developer is building a reusable `UserDisplay` component and needs to accept the user's email address. Which naming convention for the `@Input()` property is best practice according to modern Angular guidelines to prevent ambiguity?
import { Component, Input } from '@angular/core';
@Component({
selector: 'app-user-display',
standalone: true,
})
export class UserDisplayComponent {
@Input() userEmail: string = '';
}
Check answer and explanation
Correct answer: @Input() userEmail: string = '';
Explanation
The choice "@Input() userEmail: string = '';" is correct because it avoids naming the input property after a standard DOM element attribute, thus preventing confusion.
Common trap
The choice "@Input() email: string = '';" is tempting because it is concise, but it risks colliding with native DOM properties. The choice "@Input() inputEmail: string = ''" is incorrect because adding prefixes like 'input' is unnecessary since the component context already defines the property.
Source: Angular docs: Accepting data with input properties — Choosing input names
Checked against the cited text on 2026-11-25.