'formControlName not allowing value

I use formControlName but I also need a value (data.name) for my loop. But I get an empty input because formControlName doesn´t let me set a value.

html:

<form [formGroup]="myForm" (ngSubmit)="onSubmit()">
    <table>
        <tr *ngFor="let data of readData">
            <td>
                <input type="text" formControlName="name" [value]="data.name">
            </td>
        </tr>
    </table>
    <button type="submit">Submit</button>
</form>

component:

myForm = new FormGroup ({
  'name': new FormControl(''),
});


Solution 1:[1]

Remove the "[value]="data.name". The formControl handle the value.

When you create a formControl in formGroup, don't need use ''. Remove it from the name.

myForm = new FormGroup ({
  name: new FormControl(''),
});

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mullern