user13153470
user13153470

Reputation:

How to patch value in ReactiveForm

I have a form and i am able to get data in "updateData" variable but still not able to patch values in my form

checkForUpdate()
  {
    console.log(this.updateData)
    this.myReactiveFormsDialog.patchValue({
      'username' : this.updateData.username,
      'email' : this.updateData.email
    });
  }

and while i am passing dummy data for e.g 'username' : 'test' then its patching

result of console

enter image description here

Upvotes: 1

Views: 362

Answers (1)

Santosh Shinde
Santosh Shinde

Reputation: 1212

Try like this

checkForUpdate(){
   console.log(this.updateData)
   this.myReactiveFormsDialog.patchValue(this.updateData[0]);
 }

OR

checkForUpdate(){
   console.log(this.updateData)
   this.myReactiveFormsDialog.patchValue({
       username: this.updateData[0].username,
       email: this.updateData[0].email
   });
}

Upvotes: 1

Related Questions