Title: [Feature Request] Built-in support for mapping between form/domain model · Issue #65194 · angular/angular · GitHub
Open Graph Title: [Feature Request] Built-in support for mapping between form/domain model · Issue #65194 · angular/angular
X Title: [Feature Request] Built-in support for mapping between form/domain model · Issue #65194 · angular/angular
Description: Which @angular/* package(s) are relevant/related to the feature request? forms Description When I define a signal-based form, I want to be able to provide default values for the form or form fields that are applied if the provided value ...
Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? forms Description When I define a signal-based form, I want to be able to provide default values for the form or form fields...
X Description: Which @angular/* package(s) are relevant/related to the feature request? forms Description When I define a signal-based form, I want to be able to provide default values for the form or form fields...
Opengraph URL: https://github.com/angular/angular/issues/65194
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Feature Request] Built-in support for mapping between form/domain model","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\n\nforms\n\n### Description\n\nWhen I define a signal-based form, I want to be able to provide default values for the form or form fields that are applied if the provided value is undefined.\n\nFor instance when I want to attach a mat-slide-toggle to a field that can be undefined, I get an compile error.\n\nMy main requirements:\n\n- Defaults are applied before the UI renders.\n- I can specify defaults at field level and/or globally.\n- No extraneous UI flicker from patching values after initialization.\n\n### Proposed solution\n\nIdeally, I would like to specify the default value as form option:\n\n```typescript\n@Component({\n selector: 'signal-form-default-value-example',\n template: `\u003cinput type=\"number\" [field]=\"valueForm\" />`,\n imports: [Field]\n})\nexport class SignalFormDefaultValueExample implements FormValueControl\u003cnumber | undefined>\n{\n public readonly value = model\u003cnumber>();\n protected readonly valueForm = form(this.value, { defaultValue: 42 }); // \u003c===\n}\n```\n\nand for field trees the default should be applied in a deep way.\n\n```typescript\ninterface Value { a?: number; b?: boolean }\n\n@Component({\n selector: 'signal-form-default-value-example',\n template: `\u003cinput type=\"number\" [field]=\"valueForm.a\" />\n \u003cmat-slide-toggle [field]=\"valueForm.b\"/>, // \u003c== without a default, this would cause a compile error\n imports: [Field]\n})\nexport class SignalFormDefaultValueExample implements FormValueControl\u003cValue | undefined> {\n public readonly value = model\u003cValue>();\n protected readonly valueForm = form(this.value, { defaultValue: { a: 42, b: true } }); // \u003c===\n}\n```\n\nand / or as default for the field directive:\n\n```html\n\u003cinput type=\"number\" [field]=\"valueForm.a\" [fieldDefault]=\"42\" />\n\u003cmat-slide-toggle [field]=\"valueForm.b\" [fieldDefault]=\"true\"/>\n```\n\n### Alternatives considered\n\nI've tried:\n\n- Using effects to patch missing values, but the UI briefly shows no/default state, causing flicker. Or I get type errors when I want to pass a field to an edit component that requires a value\n\n- Separating the value input and valueChange output and a linkedSignal in between to patch the default there - but the FormValueControl expects a value _model_, so I can't split input and output.\n\nDid I miss something?","author":{"url":"https://github.com/ptandler","@type":"Person","name":"ptandler"},"datePublished":"2025-11-14T12:51:27Z","url":"https://github.com/angular/angular/issues/65194"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9f8ea3db-e551-2fc6-f579-29a5e9b34db1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 877A:38E318:369EBA5:451C131:6B021CFA |
| html-safe-nonce | b6e5cb44b8ba684aec0c385e6345f5ea16574a11b244781ba66dc499c57d9bf4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzdBOjM4RTMxODozNjlFQkE1OjQ1MUMxMzE6NkIwMjFDRkEiLCJ2aXNpdG9yX2lkIjoiNzEyNjc2OTU3NTQyMDYzMjMxNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b25577b28a86e05a26b45a85a92238242700b5a19971fa3a936bc5a13c941de1 |
| hovercard-subject-tag | issue:3625489579 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/65194/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3f473994df567081aa1dc71ac954c262493b69887c325b179b32b493b0a21c15/angular/angular/issues/65194 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3f473994df567081aa1dc71ac954c262493b69887c325b179b32b493b0a21c15/angular/angular/issues/65194 |
| og:image:alt | Which @angular/* package(s) are relevant/related to the feature request? forms Description When I define a signal-based form, I want to be able to provide default values for the form or form fields... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ptandler |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width