Sumit Agarwal Sumit Agarwal - 1 year ago 365
TypeScript Question

Angular 2: Accessing data from FormArray

I have prepared a from using ReactiveForms provided by angular2/forms. This form has a form array products:

this.checkoutFormGroup ={
selectedNominee: ['', Validators.required],
selectedBank: ['', Validators.required],
products: productFormGroupArray

productFormGroupArray is a array of FormGroup Objects.I fetched the controls i.e. FormArray object using this:


I am trying to get the element in the products array at index
. How can this be done without looping through the array?


I tried with at(index) method available:


but this is generating an error as:

Property 'at' does not exist on type 'AbstractControl'.

Edit 2:
checkoutData and fund are received from server.

this.checkoutData.products.forEach(product => {
investmentAmount: [, Validators.required],
selectedSubOption: ['', Validators.required],

Answer Source

Just cast that control to array

var arrayControl = this.checkoutFormGroup.get('products') as FormArray;

and all its features are there

var item =;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download