您可以通过两种方式防止这种情况you can prevent this in two ways您可以在 *ngFor 上添加 trackBy: onTrackById*ngFor="let creds of grnGroup.controls.credentials?.value; trackBy: onTrackById; let i = index"并在 component.ts and in component.ts onTrackById(index: number, item: FormGroup) { return index; // or unique value from {item} something like this (item.get('id').value)}将 grnGroup.controls.credentials?.value 替换为 grnGroup.get('credentials').controls*ngFor="let creds of grnGroup.controls.credentials?.controls; trackBy: onTrackById; let i = index"这是带有控制台日志的简单示例,我已经复制了我所说的内容,请查看链接here is the simple example with console logs, I have reproduced what i said, Please check the link https://stackblitz.com/edit/form-array-angular-rdg8dd 这篇关于使用 FormArray 将数据显示到表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-29 02:42