manikandan r

manikandan r

  • NA
  • 334
  • 0

Angular Reactive form patchValue is not setting the data to control

Jan 19 2024 6:03 AM

Hi,

I have an edit modal popup form (reactive). while loading the modal popup form controls are not being set with the values i get from api.

Console window gets the data but patchValue block is getting skipped without assigning the actual data. 

// Load data 

this.editdata = item;    //getting projectId data correctly here in this.editdata
      this.editForm.patchValue(    ///  not working.  this line getting skipped and going out of this block
        {
          projectId:this.editdata[0].projectId,

        });

Form group initialization code:

editForm = this.builder.group({

    projectId: this.builder.control(''),

    projectType: this.builder.control(''),

    planNumber: this.builder.control(''),

    planName: this.builder.control(''),

 

 


Answers (2)