input() tạo một InputSignal đọc bằng cách gọi function, ví dụ userId(), và compose tự nhiên với computed() hoặc effect().
Ví dụ:
typescript
@Component({ template: "<p>User {{ userId() }}</p>" })
export class UserCard {
userId = input.required<string>()
displayId = computed(() => `#${this.userId()}`)
}@Input() vẫn dùng được, nhất là trong code cũ; nhưng khi viết component mới, signal input giúp template và reactive state nhất quán hơn.
input() creates an InputSignal that you read by calling it, for example userId(), and it composes naturally with computed() or effect().
Example:
typescript
@Component({ template: "<p>User {{ userId() }}</p>" })
export class UserCard {
userId = input.required<string>()
displayId = computed(() => `#${this.userId()}`)
}@Input() still works, especially in older code; but for new components, signal inputs keep templates and reactive state more consistent.