Handling Complex Situations with Template Driven Forms
The basic element of building Angular forms is the FormControl. This is a class that represents that input element on a page with a name value you’re likely used to seeing.
Any piece of information we want to collect in a form, whether it’s an input, select, dropdown, or custom element needs to have a representative FormControl. The `[formControl]` directive is used to bind the input element in the DOM to it’s respective FormControl.
FormGroup is the class that allows us to group a number of controls together. It also extends the AbstractControl class, meaning we can track the validity and value of all the FormControls in a FormGroup together.
This allows us to easily manage our form as a whole. The `[formGroup]` directive binds the FormGroup to a DOM element.
FormArray is a class that aggregates FormControls into an array, similar to FormGroup creating an object from FormControls.
FormArrays can have controls pushed to them or removed from them similar to the way you’d manipulate an array in vanilla JS, and offer us a lot of power and flexibility when creating nested and dynamic forms.
Repeatedly typing new FormControl(''), new FormGroup({}), and new FormArray([]) can become a bit tedious, especially when creating larger forms.
Angular has shorthand syntax we can use thanks to the FormBuilder class.
Harnessing Reactive Forms Knowledge
Create a component that will act as a form control and "emit" the value we want
Slides available at: tehfedaykin.github.io/HandlingAngularForms
More about forms: bitovi.com/blog