{"id":28098754,"url":"https://github.com/leolanese/angular19-forms-strategies","last_synced_at":"2025-05-13T17:58:46.286Z","repository":{"id":291847695,"uuid":"877441304","full_name":"leolanese/Angular19-Forms-Strategies","owner":"leolanese","description":"Angular (19+) Forms Patterns: Template Driven, React Driven Template and Signal Driven forms","archived":false,"fork":false,"pushed_at":"2025-04-26T11:38:07.000Z","size":438,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-06T21:20:29.485Z","etag":null,"topics":["angular"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leolanese.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-23T16:49:44.000Z","updated_at":"2025-04-28T08:14:51.000Z","dependencies_parsed_at":"2025-05-06T21:32:06.727Z","dependency_job_id":null,"html_url":"https://github.com/leolanese/Angular19-Forms-Strategies","commit_stats":null,"previous_names":["leolanese/angular19-forms-strategies"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leolanese%2FAngular19-Forms-Strategies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leolanese%2FAngular19-Forms-Strategies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leolanese%2FAngular19-Forms-Strategies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leolanese%2FAngular19-Forms-Strategies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leolanese","download_url":"https://codeload.github.com/leolanese/Angular19-Forms-Strategies/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253999877,"owners_count":21997348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular"],"created_at":"2025-05-13T17:58:46.041Z","updated_at":"2025-05-13T17:58:46.268Z","avatar_url":"https://github.com/leolanese.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Angular (19+) Forms: `Template Driven`, `React Driven Template` and `Signal Driven` \n\n## DEMO\n![](./src/assets/image.png)\n\n---\n\n## Template-Driven Form Component\n```js\nexport class PetListComponent {\n  items: Item[] = [...items];  // Direct array manipulation\n  newItemName = '';\n\n  addItem(): void {\n    if (this.newItemName.trim()) {\n      this.items.push({ name: this.newItemName.trim(), isChecked: false });\n      this.newItemName = '';\n    }\n  }\n}\n```\nKey characteristics:\n- Uses [(ngModel)] for two-way binding\n- Form state is managed directly in the component class\n- Simpler to implement but less control over form state\n- Changes are tracked through Angular's change detection\n- Good for simple forms with basic validation\n\n\n## Reactive Form Component\n```js\nexport class PetListComponent implements OnInit {\n  petForm: FormGroup;\n\n  constructor(private fb: FormBuilder) {\n    this.petForm = this.fb.group({\n      items: this.fb.array([]),\n      newItemName: ['', Validators.required]\n    });\n  }\n\n  get itemsArray(): FormArray {\n    return this.petForm.get('items') as FormArray;\n  }\n}\n```\n\nKey characteristics:\n- Uses FormGroup, FormArray, and FormControl for form state management\n- Form state is managed through reactive forms API\n- More control over form state and validation\n- Better for complex forms with dynamic fields\n- Easier to test and maintain\n- Form state is immutable and changes are tracked through form controls\n\nreactive-driven forms\n- ReactiveFormsModule is used instead of `FormsModule`\n- FormBuilder is utilized to construct FormGroup and FormArray.\n- FormArray holds the lists of cats and dogs, where each pet is a form group containing name and isChecked controls.\n The form controls are accessed dynamically using the index in the template.\n\n\n## Signal-based Form Component\n```js\nexport class PetListSignalComponent {\n  items = signal\u003cItem[]\u003e([...items]);  // Using Angular's new signal API\n  newItemName = '';\n\n  addItem(): void {\n    if (this.newItemName.trim()) {\n      this.items.update(items =\u003e [...items, { name: this.newItemName.trim(), isChecked: false }]);\n      this.newItemName = '';\n    }\n  }\n}\n```\n\n## Key characteristics:\n✅- Uses Angular's new signal() API for state management\n✅- More modern approach to state management\n✅- Better performance through fine-grained reactivity\n✅- Simpler than reactive forms but more powerful than template-driven\n✅- Changes are tracked through signals instead of change detection\n✅- Good balance between simplicity and control\n✅- Used `updateOn` for better Performance \u0026 UX\n\n---\n\n### :100: \u003ci\u003eThanks!\u003c/i\u003e\n#### Now, don't be an stranger. Let's stay in touch!\n\n\u003ca href=\"https://github.com/leolanese\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n  \u003cimg src=\"https://scastiel.dev/api/image/leolanese?dark\u0026removeLink\" alt=\"leolanese’s GitHub image\" width=\"600\" height=\"314\" /\u003e\n\u003c/a\u003e\n\n##### :radio_button: Linkedin: \u003ca href=\"https://www.linkedin.com/in/leolanese/\" target=\"_blank\"\u003eLeoLanese\u003c/a\u003e\n##### :radio_button: Twitter: \u003ca href=\"https://twitter.com/LeoLanese\" target=\"_blank\"\u003e@LeoLanese\u003c/a\u003e\n##### :radio_button: DEV.to: \u003ca href=\"https://www.dev.to/leolanese\" target=\"_blank\"\u003eBlog\u003c/a\u003e\n##### :radio_button: Questions / Suggestion / Recommendation: developer@leolanese.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleolanese%2Fangular19-forms-strategies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleolanese%2Fangular19-forms-strategies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleolanese%2Fangular19-forms-strategies/lists"}