Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get formcontrol name of element in an FormArray

I am using FormArray in side a form. I am able to get fines which is of type FormArray by using code below but I am not able to get controls inside FormArray element. Is there any way to get controls inside FormArray element?

createForm(): void {
    this.transactionForm = this.formBuilder.group({
      date: [this.today],
      fines: this.formBuilder.array([]),
  
    });
}
  
  
  
get fines(): FormArray {
    return this.transactionForm.get('fines') as FormArray;
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It can be done by using index followed by get() with the name of the control which you would like to get :

    const lines = this.transactionForm.get('lines') as FormArray;
      
    // suppose you have a control with name notes then  
    console.log('notes', lines.controls[0].get('notes'));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading