Trung BìnhAngular iconAngular

Signal input `input()` khác `@Input()` truyền thống thế nào?

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.

Xem toàn bộ Angular cùng filter theo level & chủ đề con.

Mở danh sách Angular