608 questions
100
votes
4
answers
126k
views
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(): ...
24
votes
4
answers
50k
views
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 ...
18
votes
7
answers
28k
views
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';
...
15
votes
1
answer
37k
views
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 ...
13
votes
1
answer
23k
views
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:
...
12
votes
4
answers
17k
views
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 ...
10
votes
1
answer
25k
views
Angular Reactive Form with dynamic fields
I'm currently battling with Angular form array.
I have a form in which I add the fields dynamically.
I have created the form object:
this.otherDataForm = this.fb.group({
});
I add the dynamic ...
9
votes
1
answer
8k
views
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: '...
7
votes
2
answers
14k
views
Angular - How to initiate FormArray from an existing array?
I would like to create an editable table with FormArray.
For this, I have the results attribute that is rendered in the table.
What's the proper way to initialize it with FormArray data?
results: ...
7
votes
4
answers
10k
views
Angular2 patchValue JSON data to formArray
I have a Json data like this:
assets/details.json
{
"name" : "john",
"age" : 20,
"address" : [{
"main": "address1",
"sub": "address2"
},
{
"main": "add1"...
6
votes
2
answers
26k
views
patchValue on a FormArray object?
I have an array of languages for a user to select and a default language to pick. When a default language is selected, I want to make sure the checkbox for that language is also selected ...
6
votes
2
answers
5k
views
How to correctly use types with FormArray in Angular
How should I declare this type ?
Let say I've a FormGroup
I instantize it in the constructor.
export interface MyType {
myValue: string
}
myForm: FormGroup
myArray: FormArray // <FormControl<...
6
votes
3
answers
10k
views
Detect changes of FormArray children
I have a FormArray with different FormControl items inside it.
I want to be able to listen to the change event of any of them.
I tried to do this:
this.form = this.fb.group({
items: this.fb....
6
votes
1
answer
2k
views
How to pass additional data to a reactive dynamic form in Angular
I have an array with combination of editable (will be formControl object) and read-only data(will be a static text on the HTML). Is there a way to do that in Angular? I can use FormArrays and ...
5
votes
2
answers
2k
views
Why Angular ReactiveForms FormArray throws error "TypeError: Cannot read property 'updateOn' of null"
Hello All I have a Formarray which which has set of Roles. During Edit it dynamically removes & adds roles in that form array till here all works fine, but when i submit the form it thorws error &...
5
votes
3
answers
34k
views
How to push to a FormArray([ ]) in angular 4
I have a reactive angular form that looks something like this.
<form [formGroup]="myForm">
<div *ngFor="let Repo of Repos;">
<fieldset>
<legend&...
5
votes
2
answers
2k
views
Angular FormArray or FormGroup - With Extra Data
I have a table that is dynamically created and it displays data as follows:
<table>
<tr *ngFor="let product of products">
<td>{{product.name}}</td>
<td>{{...
4
votes
3
answers
6k
views
Angular 8 - FormArray "No value accessor for form control with path"
I'm using ng-select on a form, but now I want to wrap a specific configuration of this on a custom component. The problem is I'm using a FormArray which contains several of this, in the next way:
this....
4
votes
1
answer
2k
views
What is the difference between FormGroup and FormArray? When to use what?
I have multiple dynamic FormGroups in my code.
Also, some FormGroups have a feature to add multiple FormGroups/FormControls.
So while creating FormGroup dynamically I have used FormBuilder.group() ...
4
votes
2
answers
4k
views
Expandable Rows in p-table with nested FormArray in Angular
I am working with Prime-ng, and I need to expand my registration forms with FormArray and continue to dynamically display other child forms. The image shows what I'm trying to achieve.
In my ...
4
votes
1
answer
16k
views
How to find index of form from FormArray that contain error in angular?
I am working with one complex form in angular and I need some help. let me explain my scenario in detail.
I have one formArray like this :
let slides = new FormArray([]);
slides.push(getNewSlide())
...
4
votes
3
answers
4k
views
How to remove all elements of a FormArray but one specific index?
Is there any built-in functionality in Angular, so that I can say:
remove all FormArray elements except at index 2
maybe something like 'RemoveRange" as known from other libs?
4
votes
2
answers
2k
views
Angular removeAt always remove last element from FormArray
I have following form. arr is a list of FormBuilder.
get arr() {
return this.form.get('arr') as FormArray;
}
this.form = this.fb.group({
id: this.fb.control(''),
name: this.fb....
4
votes
1
answer
5k
views
How to update reactive form field value when other field value changes
I have below reactive form where I'm using form builder with group.
Fig:
Here is the HTML code of the component
<div class="">
<form [formGroup]="FeedBack" (...
3
votes
1
answer
18k
views
Angular FormArray setValue with data from Service
I have a Problem with FormArray and could need some help.
I have a form with variable FormArray and it works and I can send the data to the backend.
The problem is, that I cant set the values from the ...