angular / angular/components

feat(inputs): Add `[readonly]` property to input components

Đang mở
#27,955 9 bình luận 16 reaction 0 người được giao Xem trên GitHub
feature P4
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

### Feature Description

Right now input components (checkbox, chips, datepicker, form field, radio button, select, slider) have `[disabled]` property. Only `matInput` directive has `[readonly]`.

`[disabled]` property conflicts with the `[formControl]` directive, which has a [property with the same name](https://github.com/angular/angular/blob/main/packages/forms/src/directives/reactive_directives/form_control_directive.ts#L72).

So if you use `[formControl]` with the components listed above, it is not possible to use their `[disabled]` property.

### Use Case

`[disabled]` controls [will not be included](https://github.com/angular/angular/blob/main/packages/forms/src/model/abstract_model.ts#L409) in `form.value` - sometimes you need to render an input element as read-only but still send its value to the server.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách so sánh hành vi [readonly] hiện có trên directive matInput với các component checkbox, chips, datepicker, form field, radio button, select và slider. Đọc tài liệu được liên kết về thuộc tính FormControlDirective và AbstractControl để hiểu tương tác giữa disabled và value. Hoàn thành nghĩa là mỗi component được liệt kê đều hỗ trợ [readonly] mà không loại value của nó khỏi form.value.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
frontend
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.