更新时间:2023-11-02 17:04:34
问题是,当chipList的FormArray
状态为INVALID
时,未将chipList的errorState
设置为true
.
The problem is that the chipList's errorState
isn't set to true
when the chipList's FormArray
status is INVALID
.
我正面临着同样的问题,不知道为什么这不能立即解决,或者如何使用chipList的形式为FormArray
隐式实现.
I'm facing the same problem and don't know why this isn't working out of the box or how this can be achieved implicitly with the chipList's form being a FormArray
.
作为一种解决方法,您可以从FormArray
听状态更改并手动设置chipList的errorState
:
As a workaround you can listen to status changes from the FormArray
and set the chipList's errorState
manually:
@ViewChild('chipList') chipList: MatChipList;
ngOnInit() {
this.myForm.get('names').statusChanges.subscribe(
status => this.chipList.errorState = status === 'INVALID'
);
}