Title: Add Documentation how to programmatically set Input Signals · Issue #54987 · angular/angular · GitHub
Open Graph Title: Add Documentation how to programmatically set Input Signals · Issue #54987 · angular/angular
X Title: Add Documentation how to programmatically set Input Signals · Issue #54987 · angular/angular
Description: Describe the problem that you experienced There is no documentation on how to set Input Signals programmatically. Enter the URL of the topic with the problem https://angular.io/guide/signal-inputs Describe what you were looking for in th...
Open Graph Description: Describe the problem that you experienced There is no documentation on how to set Input Signals programmatically. Enter the URL of the topic with the problem https://angular.io/guide/signal-inputs ...
X Description: Describe the problem that you experienced There is no documentation on how to set Input Signals programmatically. Enter the URL of the topic with the problem https://angular.io/guide/signal-inputs ...
Opengraph URL: https://github.com/angular/angular/issues/54987
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add Documentation how to programmatically set Input Signals","articleBody":"### Describe the problem that you experienced\n\nThere is no documentation on how to set Input Signals programmatically. \n\n### Enter the URL of the topic with the problem\n\nhttps://angular.io/guide/signal-inputs\n\n### Describe what you were looking for in the documentation\n\nhttps://stackblitz.com/edit/stackblitz-starters-nmnsbz?file=src%2Fmain.ts\r\n\r\n```ts\r\nexport function setValueOfInputSignal\u003cT>(signal: InputSignal\u003cT>, value: T) {\r\n const node = signal[SIGNAL];\r\n\r\n // Both work\r\n\r\n // signalSetFn(node, value);\r\n\r\n node.applyValueToInputSignal(node, value);\r\n}\r\n```\n\n### Describe the actions that led you to experience the problem\n\n- Migrating from getter/setter with Input Decorator + private property signal or observable pattern => Can't set values anymore: This is painful, when you have a reference to a component (but not the template) and wan't to set values\r\n- Testing a component with Input Signals => a container component is needed, see example below\r\n\r\nTesting a component with a Input Signal without the ability to programmatically set the signal:\r\n```ts\r\n// my-component.spec.ts\r\n\r\nfunction render(template: string, params?: object, providers?: Provider[]) {\r\n @Component({\r\n imports: [\r\n // ...\r\n ],\r\n standalone: true,\r\n template,\r\n providers,\r\n })\r\n class Container {}\r\n\r\n const fixture = TestBed.createComponent(Container);\r\n\r\n const detectChanges = fixture.detectChanges.bind(fixture);\r\n\r\n fixture.detectChanges = (checkNoChanges) => {\r\n Object.assign(fixture.componentInstance, params);\r\n detectChanges(checkNoChanges);\r\n };\r\n\r\n fixture.detectChanges();\r\n\r\n const componentInstance = fixture.debugElement.query(\r\n By.directive(MyComponent),\r\n ).componentInstance;\r\n\r\n return { fixture, componentInstance };\r\n}\r\n\r\n// usage\r\nconst params = { foo: 42 };\r\nconst { fixture } = render('\u003cmy-cmp [foo]=\"foo\" />', params);\r\nparams.foo = 99;\r\nfixture.detectChanges();\r\n``` \n\n### Describe what you want to experience that would fix the problem\n\nDocumentation on how to set Input Signals programmatically. \n\n### Add a screenshot if that helps illustrate the problem\n\n_No response_\n\n### If this problem caused an exception or error, please paste it here\n\n_No response_\n\n### If the problem is browser-specific, please specify the device, OS, browser, and version\n\n_No response_\n\n### Provide any additional information here in as much as detail as you can\n\n```true\nThank you for reading, I would love to hear your thoughts on this! :)\n```\n","author":{"url":"https://github.com/RobbyRabbitman","@type":"Person","name":"RobbyRabbitman"},"datePublished":"2024-03-21T22:55:15Z","url":"https://github.com/angular/angular/issues/54987"}
| 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:440a6ba1-0f8a-32e8-91de-9ed0c9358519 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D3DC:B53AF:106B06F:15E0681:6B0113BC |
| html-safe-nonce | 045bfcbe4e8af2af3d98758474b9ac6f6c1538a23eb70d5be53c0985f09eb2b7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0RDOkI1M0FGOjEwNkIwNkY6MTVFMDY4MTo2QjAxMTNCQyIsInZpc2l0b3JfaWQiOiI2NTEwNDc3MTA3NDM1NDc1OTAwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c392563ecf357259931c4d1a8870c5381d04be977fe8c9a80ed312af2bb085b9 |
| hovercard-subject-tag | issue:2201332455 |
| 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/54987/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ddfa40b201f74ff22ac1a96c821aa96c1c95874d95e8c8090efdd31167da21ea/angular/angular/issues/54987 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ddfa40b201f74ff22ac1a96c821aa96c1c95874d95e8c8090efdd31167da21ea/angular/angular/issues/54987 |
| og:image:alt | Describe the problem that you experienced There is no documentation on how to set Input Signals programmatically. Enter the URL of the topic with the problem https://angular.io/guide/signal-inputs ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RobbyRabbitman |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width