get beans() { return this.validateForm.get('beans') as FormArray; } change(fromIdx, toIdx){ const formGroup = this.beans.at(fromIdx); this.beans.removeAt(fromIdx); this.beans.insert(toIdx, formGroup); } trackByFn(index: any, item: any) { return index; } 同时需要在ng-for循环部分增加trackBy *ngFor="let item of beans.controls; let i = index; trackBy:trackByFn"
标签:index,fromIdx,toIdx,位置,FormArray,trackBy,beans,调整 From: https://www.cnblogs.com/MainActivity/p/16665612.html