{{ 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()}`); } ``` ### Используйте `readonly` для свойств, которые не должны меняться {#use-readonly-for-properties-that-shouldnt-change} Помечайте свойства компонентов и директив, инициализируемые Angular, как `readonly`. Это включает свойства, инициализируемые через `input`, `model`, `output` и queries. Модификатор доступа readonly гарантирует, что значение, установленное Angular, не будет перезаписано. ```ts @Component(/* ... */) export class UserProfile { readonly userId = input(); readonly userSaved = output(); readonly userName = model(); } ``` Для компонентов и директив, использующих декораторные API `@Input`, `@Output` и queries, этот совет относится к output-свойствам и queries, но не к input-свойствам. ```ts @Component(/* ... */) export class UserProfile { @Output() readonly userSaved = new EventEmitter