I have a FormArray in PreprocesssingForm. Here, Sequence No is not getting changed when I add a new row.
<tr class="mat-row" *ngFor="let dynamic of PreprocessingForm.controls.arithmeticItems['controls']; let i = index" [formGroupName]="i">
<td> {{ i+1 }} </td>
<td class="mat-cell">
<mat-form-field appearance="outline" style="width: 4rem;text-align: center;">
<input matInput formControlName="operational_sequence_no" type="text" value = {{ i+1 }} readonly>
</mat-form-field>
</td>
<td> {{ i+1 }} </td>
is showing correctly 1 2 3 4 5.
I tried value = {{i+1}}, [value] = "i+1", value = "{{i+1}}"
.
But, It is showing 1 1 1 1 1.
[ngModel] = "i+1"
is working, but console is telling that it is depreceated.
if you use FormControl not use "value". You should give value to the FormControl
I imagine you have a getter(*)
And a function that return a formGroup
When add an element
The only is change your newArithmeticItem like:
But... be careful, if you remove an item you should "recalculate" the "operational_sequence"
(*)I know you have not, but it's good to have a getter of the formArrays