mat-selection-list list-options is not updated when formControl for mat-selection-list is updated with setValue
- 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ả
#### What is the expected behavior?
Checkboxes should update
#### What is the current behavior?
Checkboxes do not update.
#### What are the steps to reproduce?
**editor.componenet.html**
```html
{{ role.attributes.name }}
```
**editor.component.ts (onInit)**
```javascript
this.form = this.fb.group({
role: [[...this.user.attributes.role], Validators.required],
});
```
`this.user.attributes.role` is an array of string.
**I tried**
**editor.component.ts**
```javascript
ngAfterContentInit() {
this.form.patchValue({
'role': [...this.user.attributes.role]
});
}
```
**I also tried**
**editor.component.ts**
```javascript
ngAfterContentInit() {
setTimeout(() => {
this.form.patchValue({
'role': [...this.user.attributes.role]
});
console.log(this.form.value.role);
}, 1000);
}
```
Note that I'm getting `roles` with an observable :
**editor.component.ts**
```javascript
combineLatest(
// Others observables ...
this.jsonApi.all('roles').pipe(map(document => document.data)),
).subscribe(([firms, langs, roles]) => {
// Others observables ...
this.roles = roles;
});
```
#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 7.x.x
Material 7.x.x
#### Is there anything else we should know?
I know there's a [ticket](https://github.com/angular/material2/issues/9085) about this, but it's closed and no one replies
Hướng dẫn đóng góp
Hướng nghiên cứu
Tái hiện vấn đề bằng cách sử dụng editor.component.html và editor.component.ts với một Angular 7 mat-selection-list, các role bất đồng bộ và formControl setValue hoặc patchValue. Bắt đầu bằng cách lần theo quá trình truyền giá trị của mat-selection-list và mat-list-option; hoàn thành có nghĩa là các hộp kiểm phản ánh mảng chuỗi đã được cập nhật sau khi form được cập nhật.
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
- Lỗi
- Độ 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