react-reactive-form icon indicating copy to clipboard operation
react-reactive-form copied to clipboard

To remove multiple controls from dynamic FormArray not working with removeAt

Open MartinJesu opened this issue 4 years ago • 0 comments

Describe the bug To remove multiple controls from dynamic FormGroup not working with removeAt. My case i want to remove multiple FormControls from FormGroup then need to push new multiple FormControls in the same FormGroup. At that time removeAt will not worked.

If i loop through my FormGroup & try to use removeAt it will execute only one time then break the loop, also i have other logic codes below that also not executable.

I tried like below code,

control.meta.currentForm.controls['dynamicSelector']['controls'].forEach((child, index) => { child.removeAt(index); });

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

MartinJesu avatar May 19 '20 17:05 MartinJesu