Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

form.reset() does not reset FormArray length #10960

Closed
seklyza opened this issue Aug 19, 2016 · 4 comments
Closed

form.reset() does not reset FormArray length #10960

seklyza opened this issue Aug 19, 2016 · 4 comments
Labels
area: forms feature Issue that requests a new feature

Comments

@seklyza
Copy link
Contributor

seklyza commented Aug 19, 2016

I'm submitting a ... (check one with "x")

[] bug report => search github for a similar issue or PR before submitting
[x ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

I have a form in Angular2 using the Data-Driven method, and when I use form.reset(), the controls are getting cleared, the values of the controls in an FormArray are getting cleared but the amount of the controls aren't (Inside a FormArray).

Expected/desired behavior

I expect that form.reset() will clear also the FormArray (reset their value and amount)

Reproduction of the problem
Plunker: http://plnkr.co/edit/RKWPWC7PBh8yNJvkcWWc

What is the expected behavior?

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • Angular version: 2.0.0-rc.5
  • Browser: [all]
  • Language: [TypeScript]
@seklyza seklyza changed the title form.reset() does not reset FormArray form.reset() does not reset FormArray length Aug 19, 2016
@seklyza
Copy link
Contributor Author

seklyza commented Aug 20, 2016

Any thoughts?

@kara kara added feature Issue that requests a new feature area: forms labels Aug 24, 2016
@kara
Copy link
Contributor

kara commented Aug 25, 2016

@seklyza The current reset() function mimics a regular HTML5 form reset, so it only clears existing inputs and doesn't remove any inputs that are added programmatically later.

If you want to remove the added controls, rebinding the FormGroup might be cleaner. #11051 will make this possible.

@kara
Copy link
Contributor

kara commented Aug 25, 2016

Closing, as #11051 gives you a way to do this.

@kara kara closed this as completed Aug 25, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: forms feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

2 participants