0

SectionService form

this.form = this.fb.group({
      siteDestinationSectionsList: this.fb.array([this.siteDestinationSectionsListGroup]),
   // removed rest
    });

siteDestinationSectionsListGroup =
     this.fb.group({
      siteCodeId: ['',Validators.required],
      description: [''],
// removed rest
    });

component.ts

get siteDestinationSectionsListArray() {
    return this.techneSectionForm.get('siteDestinationSectionsList') as FormArray;
  }

I try to get the values of siteDestinationSectionsListArray

console.log("siteDestinationSectionsListArray", this.siteDestinationSectionsListArray);

In console siteDestinationSectionsListArray

I want the value of siteCodeId. How can I get that?

I tried with console.log("siteDestinationSectionsListArray.value", this.siteDestinationSectionsListArray.value); But I got [ { "siteCodeId": "", "description": "", "links": [], "images": [] } ] Here siteCodeId is "" But The siteDestinationSectionsListArray has siteCodeId is 3. Why I could not get siteCodeId as 3 ?

2 Answers 2

2
this.siteDestinationSectionsListArray.at(index)

and then you can access the field that you want, in your case .siteCodeId

Sign up to request clarification or add additional context in comments.

Comments

2

You should be able to get it by using the FormArray's at(index) method.

this.siteDestinationSectionsListArray.at(0).value.siteCodeId

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.