I have successfully retrieved data from the database and need to pre-fill an update form with preset values. The issue I am facing is that when I add FormControlName to the input field, it removes the preset values. I have tried using setValue and patchValue methods but to no avail. Any suggestions on why this might be happening or a possible solution? Thank you in advance.
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>
ngOnInit() {
this.currUserId = this.userId$.value;
this.authService
.findOne(this.currUserId)
.pipe(map((user: User) => (this.currentUser = user)))
.subscribe();
}
<div class="tab-container" *ngIf="currentUser">
<form [formGroup]="accountForm" (ngSubmit)="submit()">
<ion-card class="personal-form">
<h3>Personal Details</h3>
<div class="form-input">
<label>FirstName</label>
<input
formControlName="firstName"
type="text"
value="{{currentUser.firstName }}"
/>
</div>
<div class="form-input">
<label>surname</label>
<input
formControlName="surname"
type="text"
value="{{ currentUser.surname }}"
/>
</div>
</form>
</div>