Issue
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
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'));
                            Answered By - H S Progr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.