I'm having trouble with my dynamic reactive form, as the value is not showing up
<div *ngFor="let deliveryAcross of (deliveriesAcross | async)!; let i = index;">
<app-delivery-across
[index]="i"
[deliveryAcross]="deliveryAcross"
></app-delivery-across>
{{ deliveryAcross | json }}
</div>
deliveryacross.component.ts
@Input("deliveryAcross") deliveryAcross: IDeliverAcross;
minFormControl: FormControl;
errorStateMatcher: NextErrorStateMatcher;
constructor(private change: ChangeDetectorRef, private store: Store) {
this.deliveryAcross = {
iso: "",
min: 1,
max: 2,
shippingCents: 0,
shippingEuros: 0,
};
this.minFormControl = new FormControl("", [
Validators.required,
Validators.min(1),
]);
this.errorStateMatcher = new NextErrorStateMatcher();
}
I am unable to use ngModel
due to readonly errors, so I opted for using value instead. However, the value is not being displayed and the input keeps refreshing back to empty
<mat-form-field
class="full-width"
[@transformRightLeftStateTrigger]="stateDown | async"
>
<input
matInput
[formControl]="minFormControl"
[errorStateMatcher]="errorStateMatcher"
placeholder="Minimaal"
appDeliveryAcross
[value]="deliveryAcross.min"
autocomplete="off"
[key]="'min'"
[component]="'delivery-across'"
type="number"
/>
</mat-form-field>
Any idea why the value from deliveryAcross.min
is not displaying in the input field?