I'm facing issue in mat-table, my input field is not working properly inside table. All rows are using one input field. Means if I type text inside the input box, all rows showing that text
my code:
<ng-container matColumnDef="Remarks">
<mat-header-cell *matHeaderCellDef>scheduled hours</mat-header-cell>
<mat-cell *matCellDef="let element">
<mat-form-field>
<input matInput [(ngModel)]="Remarks" (input)="$event.target.value.length > 2 && Remarks($event.target.value)" name="AppRemarks" #AppRemarks="ngModel" placeholder="Remarks">
</mat-form-field>
</mat-cell>
</ng-container>
Hi there its not the fault of the mat table you are making a table out of the same variable and each row has two way binding for the same variable this will result in the each row will have the same value.
In order to achive what you wanted please take a look at Angular Reactive formarrays.
Here is a pretty good tutorialhow to use formarrays https://netbasal.com/angular-reactive-forms-the-ultimate-guide-to-formarray-3adbe6b0b61a