in Angular Reactive forms - i have array like this 3 items :
productList = [{
productId : "104",
productName : computer
},
{
productId : "105",
productName : sprots
},
{
productId : "106",
productName : location
}]
declared form group like this :
this.productFormGroup = this.formBuilder.group({
productFormArray: new FormArray([], CustomValidators.minNumberInputFieldRequired(1)),
});
creating input fields like this :
productList.forEach((element) => {
productFormArray.push(new FormControl('', [Validators.pattern(ValidationPatterns.required)]));
});
bind like this :
<div *ngFor="let item of formControls; let i = index">
<input type="text" [formControlName]="i" class="form-control">
</div>
Question :
how do i get 3 textbox updated value with their id on submit button?
Submit Button Event : -
if (this.productFormGroup.invalid) {
return;
}
this.productFormGroup.value.productFormArray ? - it is return only update value, not Id.
there should be way to create text box with id while pushing item in form Array