Cơ BảnAngular iconAngular

Two-way binding `[(ngModel)]` hoạt động thế nào?

[(ngModel)] là cú pháp banana-in-a-box kết hợp property binding và event binding: dữ liệu đi xuống input, thay đổi từ input đẩy ngược lên model.

Nó thuộc FormsModule và phù hợp với form đơn giản. Với form phức tạp, validation nhiều bước hoặc test nghiêm túc, nên dùng Reactive Forms vì model explicit hơn.

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

Mở danh sách Angular