Questions tagged [formarray]

For questions about Angular FormArray, a built-in building block used to define forms. It tracks & controls the value and validity of an array of FormControl, FormGroup, or FormArray instances. Available in @angular/forms package.

Angular FormArray is a building block in @angular/forms package, used to define forms. Other building blocks are FormControl and .

It tracks & controls the value and validity of an array of FormControls, FormGroups, or FormArrays and combines values of each into an array.

Related tags: , ,

See the official guide for a detailed introduction to FormArray .

588 questions
93
votes
4 answers

TypeScript. FormGroup FormArray - remove only one element object by value. Angular 2 4

this.formGroup = this.formBuilder.group({ images: this.fb.array([]) }); I add new element in this way: this.images.push(new FormControl(new ImageCreateForm(this.imageResponse.id))); get images(): FormArray { return…
el_konrad
  • 1,211
  • 2
  • 11
  • 12
50
votes
3 answers

Angular Reactive Forms with nested Form Arrays

I'm new to Angular 2 and decided the best way to learn would be to go through the official Angular guides. I went through the Reactive Forms Guide https://angular.io/guide/reactive-forms demo link: https://stackblitz.com/angular/jammvmbrpxle While…
JR90
  • 527
  • 1
  • 6
  • 8
23
votes
4 answers

How to get index of changed item in angular form array

I'm using Angular 4 with reactive forms. I have a form array that I am trying to tie to an array I keep track of in my component. I'm using reactive forms so I can have the validation, so I don't want to use the template forms approach. I add items…
Kevin
  • 827
  • 1
  • 7
  • 18
19
votes
7 answers

Unable to patch data to FormArray

Unable to patch values to FormArray resultList. Anybody can please explain me, what i'm missing? TS File: import { Component, OnInit } from '@angular/core'; import { Student } from '../student'; import { FormGroup, FormControl, Validators, FormArray…
Santosh Jadi
  • 1,479
  • 6
  • 29
  • 55
15
votes
2 answers

Reactive Forms: How to add new FormGroup or FormArray into an existing FormGroup at a later point in time in Angular till v14

In the other examples at StackOverflow there are many questions about using FormGroups in FormArrays. But my question is the opposite. FormArrays have a push method, that makes many things possible. FormGroups have indeed an addControl method for…
user3025289
14
votes
4 answers

Kendo : Insert a FormGroup at a top into a FormArray

Problem Statement : In below stackblitz demo, I am able to insert the FormGroup dynamically at the starting of the grid on clicking the Add button and triggering the (blur) event from one control to update the value of another control sharing same…
Debug Diva
  • 26,058
  • 13
  • 70
  • 123
14
votes
2 answers

Angular FormArray: Cannot find control with path

I trying to build an Angular Reactive form where an account can add many students. The form seems to work. When you hit Add Student it creates a new student but you check the console it says ERROR Error: Cannot find control with path:…
Ty Tran
  • 143
  • 1
  • 1
  • 5
14
votes
1 answer

How to give formControlName to a FormArray object - Angular 2 (ReactiveFormsModule)

In my application I made a form using Reactive Forms. In my app their is a button Add new Fields upon clicking this button new fields are added. I am able to add new fields but I am not able to assign formControlName. Could any one please show me…
Rahul
  • 5,594
  • 7
  • 38
  • 92
12
votes
1 answer

How to make cascading dropdown in a Angular Reactive Formarray work without messing the dropdown value

I have a form in angular 4 that containing First Name + Last Name and a formarray containing 2 dropdown(select) working as cascading dropdown and a delete button. The rest of the form also contains a send button and a add option button. I added a…
11
votes
4 answers

FormArray inside Angular Material Table

Note: I succeded doing FormArray inside classic HTML Table, as seen below . I want to have a FormArray inside Angular Material table and to populate it with data. I tried the same approach as with classic HTML Table, but i was not able to compile it…
11
votes
1 answer

Angular FormArray patchValue error: TypeError: value.forEach is not a function - how to resolve?

Page was originally written as a template driven form, but is being converted to reactive in order to add auto-save feature. In the page component's constructor I define the reactive form variable: this.form = fb.group({ reviewer: '', …
lynnjwalker
  • 741
  • 5
  • 11
  • 25
10
votes
1 answer

When is Angular's FormArray a traditional array and when is it a FormArray object?

I've built a custom input component with ControlValueAccessor and it works great to add tags as selections. (Stackblitz) My problem is: when I implement the component within a form (cities & states controls) add values to both controls by selecting…
Ben Racicot
  • 5,332
  • 12
  • 66
  • 130
10
votes
3 answers

Angular2: Cannot find form control at index 1 at FormArray

During runtime I am getting all records from the JSON object and in form-control I am getting the values. However, in form-array I am getting only the first of many records. The error shown in the console: Cannot find form control at index 1 at…
Ghanshyam Dhanore
  • 103
  • 1
  • 1
  • 8
8
votes
1 answer

Filtering a Form Array in Angular

I have a list which I transform into a FormArray to generate a list of buttons in html. I want to filter the cars by name CarComponent.html
TropicalViking
  • 407
  • 2
  • 9
  • 25
7
votes
1 answer

angular (form array) value changes is not working

Form array value changes is not working. I can't console the value inside subscriber method. Here is my basic form array code below. ordersData = [ { id: 100, name: 'order 1' }, { id: 200, name: 'order 2' }, { id: 300, name: 'order 3'…
1
2 3
39 40