-
Notifications
You must be signed in to change notification settings - Fork 26.2k
feat(forms): clear (remove all) components of a FormArray #28918
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! The change looks good, but needs more docs. Can you also add more information on how to use this new feature to the commit message itself?
This method is a more convenient and efficient way of removing all components from a FormArray. Before it, we needed to loop the FormArray removing each component until empty. Resolves #18531
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for updating the docs!
@IgorMinar Could you take a look at the public API changes? |
This PR would be great feature, it will minimize code base and is much cleaner api for performing the task .👍 |
Thanks! |
…28918) This method is a more convenient and efficient way of removing all components from a FormArray. Before it, we needed to loop the FormArray removing each component until empty. Resolves angular#18531 PR Close angular#28918
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Resolves #18531
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
To remove all elements we have to loop removing the 1st element until empty:
Issue Number: #18531
What is the new behavior?
formArray.clear();
Might be a little faster as
updateValueAndValidity()
is called only once instead of for each control being removed.Does this PR introduce a breaking change?
Other information
removeAll
may be an alternative name ifclear
is ambiguous (what are we clearing? values? validators?)