Can anyone assist me in identifying the issue with this code?
<div *ngFor="let element of list; let index=index">
<mat-form-field>
<input matInput type="string" [(ngModel)]="element" name="element" #field="ngModel">
</mat-form-field>
</div>
An error message is being displayed:
ERROR: Cannot assign the value "$event" to template variable "element". Template variables are read only
I attempted the following solution:
<div *ngFor="let element of list; let index=index">
<mat-form-field>
<input matInput type="string" [(ngModel)]="list[index]" name="element" #field="ngModel">
</mat-form-field>
</div>
The above solution works, however, there is an issue where the input field only allows one character to be typed at a time. Each character needs to be individually clicked inside the input box before typing.