I am using formArray for my list of product. I want to get the product_code's value in .ts just like [ngModel] and then manipulate the data. How to get the product_code's value?
<tbody formArrayName="products">
<tr *ngFor="let phone of productForms.controls; let i=index" [formGroupName]="i">
<th scope="row">{{i+1}}</th>
<td><input type="text" class="form-control" placeholder="Product Code" formControlName="product_code"></td>
<td><input type="text" class="form-control" placeholder="Product Name" formControlName="product_name"></td>
<td><button type="button" class="btn btn-danger ml-2" (click)="deleteProduct(i)">Remove</button></td>
</tr>
</tbody>
.ts code:
ngOnInit() {
const product = this.fb.group({
product_code: [],
product_name: [],
product_price: [],
product_quantity: [1],
product_total: []
});
this.myForm = this.fb.group({
products: this.fb.array([product]),
}
}
get productForms() {
return this.myForm.get('products') as FormArray;
}
addProduct() {
const product = this.fb.group({
product_code: [],
product_name: [],
product_price: [],
product_quantity: [1],
product_total: []
});
this.productForms.push(product);
}
deleteProduct(i) {
this.productForms.removeAt(i);
}
For more clarification see this:

When i enter any number in the product_code field i need that value in .ts code which also handles the changes or say subscription.
I want to get the product_code value, perform some function and assign the return value to product_name. I know how to achieve this using ngModel two way bindings, but how to do using FormControl or say Reactiveforms?
stackblitzwith ngModel that you want to archive. After that i will convert it with Reactiveforms