When I add one product in my form, show this error. My code ts:
this.products = this.ps.getProduct();
this.addform = this.fb.group({
'invoice_number': new FormControl('', [Validators.required, Validators.nullValidator]),
'Subtotal': new FormControl('', Validators.required),
'products': this.fb.array([
]),
'total': new FormControl('', Validators.required),
});
Model class:
export class Sale {
invoice_number: number;
products: Products[];
}
My HTML code:
<form [formGroup]="addform" (ngSubmit)="onaddsale()">
<div class="contant">
<div class="row">
<div class="input-field col s4">
<input formControlName="invoice_number" id="invoice_number" type="text" class="validate">
</div>
</div>
</div>
<tr formArrayName="products" class="group" style="cursor: pointer" *ngFor="let item of products; index as i" [formGroupName]="i">
<td>
<input formControlName="Subtotal" [(ngModel)]="item.Subtotal" readonly type="number" />
</td>
<td>
<input formControlName="total" [(ngModel)]="item.total" readonly type="number" />
</td>
</tr>
</form>
In my HTML doesn't display nothing, also show my error in console.
Can you suggest what is the problem, how to solution this?