I am facing an issue with my form. Initially, I created a simple form to create a product with the following details:
Description: "fff"
Line_num: "4"
Quantity: 545
Subtotal: 3027475
Unit_price: 5555
product_id: "11E826CB009A1864B430FA163EBBBC1D"
product_type_id: "11E7FC041F467AD4B09D00FF76874A55"
Next, I created a form group called addsale where I included the product value along with some additional values. In the component ts file, I fetched the product using this code,
this.products = this.ps.getProduct();
and successfully displayed the value in the console log.
Here is how I structured my form in the ts file:
this.addsale = new FormGroup({
'invoice_number': new FormControl('', [Validators.required, Validators.nullValidator]),
'invoice_date': new FormControl('', Validators.required),
'client_id': new FormControl('', Validators.required),
'amount_paid': new FormControl('', Validators.required),
'notes': new FormControl('', Validators.required),
'Subtotal': new FormControl('', Validators.required),
'products': new FormArray([]),
'total': new FormControl('', Validators.required),
'contactNo': new FormControl('', Validators.required),
'address': new FormControl('', Validators.required)
});
In the HTML file, I used the following code snippet:
<form [formGroup]="addsale" (ngSubmit)="onaddsale()">
<tbody formArrayName="products">
<tr class="form-group" style="cursor: pointer" *ngFor="let item of addsale.get('products').controls; index as i">
<td>
<input formControlName="Unit_price" type="number">
</td>
<td>
<input formControlName="Quantity" type="number">
</td>
<td>
<input formControlName="Description" type="text" name="Description">
</td>
<td>
<input formControlName="Subtotal" readonly type="number">
</td>
<td>
<button type="button" class="fa" (click)="onRemoveItem(i)">x</button>
</td>
</tr>
</tbody>
</form>
Although the console correctly displays all values, nothing is shown on the HTML page. I would appreciate any assistance or suggestions on how to resolve this issue.
Thank you