Loading topic
@angular/forms package, and both use the same classes at runtime. They differ in where the form model is defined and in who owns it. This chapter explains that difference and how each approach works internally, and gives criteria for cho4 min readinject() function. It covers one narrow job: making the reactive forms directives available to your templates. You will see where the import goes, what it actually brings in, which par3 min readReactiveFormsModule as shown in the previous chapter. It covers what a single FormControl holds, how to create one, and the mistakes people make most often when they first use it.3 min readFormControl holds a value, a status, and errors. You should already have ReactiveFormsModule available, as set up in an earlier chapter. Here you will combine several controls into one unit with `F4 min readFormControl and FormGroup. Here you connect those model objects to real HTML inputs. You will learn how the binding 4 min readFormGroup of FormControl instances and bind it to a template with formGroup and formControlName. It also assumes basic TypeScript and RxJS. Angular gives you three methods for writing values into a form model from code: setValue, patchValue, 4 min readFormControl and FormGroup instances, bind them with formGroup and formControlName, and work with standalone components. It covers the validators that ship in @angular/forms: the shape of the errors they report, how they combine, and the edge case4 min readFormControl and FormGroup instances, bind them with formGroup and formControlName, and call setValue, patchValue, and reset. You also need TypeScript generics and union types.3 min readnew FormControl and new FormGroup yourself, and that you know how strictly typed forms infer value types and what nonNullable: true does. FormBuilder adds no new capabilities. It is a shorthand for creating the same FormControl, `F3 min readFormGroup, bind it with [formGroup] and formControlName, and read valid, touched, and errors on a control. You should also know how nonNullable controls affect typing. Real data is rarely flat. A customer has an address, an address has a st4 min readFormGroup won't fit here because its keys are fixed names. A FormArray is a form control container whose children are indexed by position, 4 min readFormControl sees only that control's value, so it can't check rules like these reliably. In Angular you attach such rules to th4 min readValidatorFn, read touched and error state in a template, and use RxJS operators like map, switchMap, and catchError. You also need provideHttpClient() registered in your application config for the HTTP example.4 min readvalueChanges. That suits most fields. Some fields need a different timing. An expensive async validator should not call the server on every key pres4 min readFormGroup with FormBuilder, bind it with formControlName, and subscribe to valueChanges. It covers what disabling a control does to its value, its validation, and its parent group. It also covers why form.value and form.getRawValue() can4 min read<input>, <select>, and <textarea> work with formControlName because Angular ships a built-in adapter for each of them. A component you write yourself, such as a star rating, a color picker, or a tag selector, has no adapter. To bind it with formControlName or `[formCo4 min read