Angular Training Part 6 - Reactive Forms - Dynamically adding or removing formControls or formGroups

preview_player
Показать описание
In this video, I talk about dynamically adding or removing formControls or formGroups from a reactive form in Angular
Рекомендации по теме
Комментарии
Автор

I am also doing this kind of work like this in my component.html

<div class="form-group" *ngFor="let roomControl of let i = index">
<input type="text" [formControlName]="i" class="form-control border-input" placeholder="Room Name">
</div>

And in my component.ts
addRoomsForm: FormGroup;
this.addRoomsForm = new FormGroup({
rooms: new FormArray([])
})
insertRow() {
FormControl(''));
}

But when i clicking on button so it appends a new row with one input but with error that
""ERROR Error: Cannot find control with unspecified name attribute
What's wrong with this code?

fahadsubzwari
Автор

You need to check your console for error on every element you add

darkslayer
Автор

Hey Brother, each time when I add and remove any element every time get an error " ERROR Error: Cannot find the control with an unspecified name attribute " please give me solution of this problem

mshubhamtyagi
Автор

Does not cover adding a FormGroup... only adding to FormArray

dennisluken
Автор

Doesn't cover "Dynamically adding or removing formControls or formGroups". You are adding and removing formArray Control

HuzaifaMomin
Автор

Hey Brother, each time when I add and remove any element every time get an error " ERROR Error: Cannot find the control with an unspecified name attribute " please give me solution of this problem just see the console in the video every time you add it throws error

jigneshmistry