How I can set value before using RemoveAt(i) on Angular Reactive Form Array?
removeCustomerPhone(custIndex: number, phoneIndex: number) {
// this.customerPhones(custIndex).at(phoneIndex).setValue({
// 'IsDeleted': true
// })
this.customerPhones(custIndex).removeAt(phoneIndex, {
emitEvent : false
});
}
Following is the methods to bind phones:-
customerPhones(custIndex: number): FormArray {
return this.Addresses()
.at(custIndex)
.get('Phones') as FormArray;
}
newPhone(): FormGroup {
this.phoneForm = this.formBuilder.group({
ID:0,
phone1: '',
addressId:0,
IsDeleted:false
});
this.phoneForm.valueChanges.subscribe(a=>{
a.stateEnum = State.Modified
});
return this.phoneForm;
}
````