{{ fullName() }}
`, -}) -export class UserProfile { - firstName = input(); - lastName = input(); - -// `fullName` is not part of the component's public API, but is used in the template. - protected fullName = computed(() => `${this.firstName()} ${this.lastName()}`); -} -``` - -### Use `readonly` on properties that are initialized by Angular - -Mark component and directive properties initialized by Angular as `readonly`. This includes -properties initialized by `input`, `model`, `output`, and queries. The readonly access modifier -ensures that the value set by Angular is not overwritten. - -```ts -@Component({/* ... */}) -export class UserProfile { - readonly userId = input(); - readonly userSaved = output(); -} -``` - -For components and directives that use the decorator-based `@Input`, `@Output`, and query APIs, this -advice applies to output properties and queries, but not input properties. - -```ts -@Component({/* ... */}) -export class UserProfile { - @Output() readonly userSaved = new EventEmitter