Angular 4 patchValue based on index in FormArray
Use FormArray#at
+ AbstractControl#patchValue
:
this.items.at(index).patchValue(...);
DEMO
You can do this simply by creating a new FormControl if you want to update the hole array structure:
this.form.setControl('items', new FormControl(arrayItemsValue));
Or by removing all items before updating them :
const items = (<FormArray>this.form.get('items'));
for (let i = 0; i < items.length; i++) {
items.removeAt(i);
}
this.form.get('items').setValue(arrayItemsValue);