Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
Value of Reactive Form not being set in view due to FormControlName

I have retrieved data from the database and would like to pre-set an update form with preset values. The values are preset when the FormControlName is not set in the input field the interpolation works. Once FormControlName is added it removes it. I have tried setValue and patchValue none have worked. Any suggestions of why this would be or a potential solution? thanks in advance

        
         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>
                            
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Instead of passing value in the input element, use "formBuilder".

constructor(
  ...
  private _fb: FormBuilder,
){}



ngOnInit() {
  this.accountForm = this._fb.group({
      firstName: [''],
      surname: [''],
  });
  this.getCurrentUser();
}

getCurrentUser() {
      this.currUserId = this.userId$.value;
      this.authService
            .findOne(this.currUserId)
            .subscribe((user: User) => {
                 this.currentUser = user;
                 this.accountForm.patchValue(this.currentUser);
       });
  }
}

and remove both value="{{currentUser.firstName }}" form HTML.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!