feat(forms): WIP / Proposal, signals in reactive and template driven forms #53481
+189
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This Draft PR proposes adding signals to reactive and template-driven forms. The goal is to collect feedback from the community and the core team.
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?
Currently, Angular forms don't support signals natively. Although through AbstractFormControl, valueChanges and statusChanges can be used together with reactive helpers to extract signals, there are certain drawbacks with this approach:
What is the new behavior?
signals
property on the control objects.control.signals.value()
. This allows a side-by-side existence with the previous regular form state handling.Does this PR introduce a breaking change?
Examples
Signal-based forms (template-driven forms with signals for reactivity)
You can check out this Stackblitz with the updated Angular Forms package:
https://stackblitz.com/edit/stackblitz-starters-uyjg2x?file=src%2Freactive-form.component.ts,src%2Ftemplate-driven-form-signals-option.component.ts,src%2Ftemplate-driven-form.component.ts,src%2Fsignal-based-forms.component.ts
Please let me know your feedback on this idea / proposal.
Cheers
Gion