mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
27 lines
1.2 KiB
Markdown
27 lines
1.2 KiB
Markdown
|
|
# Orphan field in signal forms
|
||
|
|
|
||
|
|
This error indicates that a `Field` instance is no longer connected to the current model structure.
|
||
|
|
Angular signal forms throw `NG01902` when a field path that previously existed can no longer be resolved as the same property in the parent object.
|
||
|
|
|
||
|
|
A common trigger is unintentionally setting a field's value to `undefined`.
|
||
|
|
In signal forms, `undefined` means "field does not exist", so an existing field can become orphaned.
|
||
|
|
|
||
|
|
## Why this happens
|
||
|
|
|
||
|
|
Signal forms keep field instances in sync with your model shape.
|
||
|
|
If code still references an older field instance after the model shape changed, Angular detects the mismatch and throws this error.
|
||
|
|
|
||
|
|
This can happen when:
|
||
|
|
|
||
|
|
- a property is removed from the model object
|
||
|
|
- a property becomes `undefined` instead of remaining present
|
||
|
|
- code holds a stale field reference across structural updates
|
||
|
|
|
||
|
|
## How to fix it
|
||
|
|
|
||
|
|
- Avoid writing `undefined` to model fields. Use `null` or another explicit value when the field should still exist.
|
||
|
|
- Keep the model shape stable while a field is in use.
|
||
|
|
- Re-read fields from the current form tree after structural updates instead of reusing stale references.
|
||
|
|
|
||
|
|
For model design guidance, see [Avoid `undefined`](/guide/forms/signals/model-design#avoid-undefined).
|