Angular Reactive Forms
https://www.pluralsight.com/courses/angular-reactive-forms
by Jim Cooper
Mod 1: Course Overview
- Course Overview
Mod 2: Getting Started with Angular Reactive Forms
- Introduction
- Angular Forms Architecture Overview
- Template Driven vs. Reactive Forms
- Cloning and Exploring Our Demo Application
- demo of InMemoryDbService
- will intercept http calls and return mock data
Mod 3: Creating Angular Reactive Forms
- Introduction
- shows how to import ReactiveFormsModule
- Adding Reactive Forms to a Project
- Creating Form Controls
- The Magic of the ControlVa lueAccessor Directive
- Providing Values to FormControls
- Creating FormGroups
- you use formControl directive when you don't have a form group
- if you have a formgGroup, you use the formControlName directive
- Submitting a Reactive Form
- use case for Partial in typescript
- Saving Submitted Form Data
- Adding Unbound FormControls to a FormGroup
- shows how to have a form element that is not visible (is it hidden input?) huh
- Creating Nested FormGroups
- use case for getRawValue on a formgroup
- use formGroupName directive for a nested formgroup
- Simplifying with FormBuilder and FormGroup.setValue()
- formBuilder simplifies the creation of a form group
- You can use this.fb.nonNullable to make all form fields non nullable
- you can override to make a field null
- if the shape of the formBuilder and your target object are the same, you can initialize the formBuilder with a one liner: this.contactForm.setValue(<name of your object instance>)
- Summary
Mod 4: Working with Input Elements and Data Types
- Introduction
- Working with Radio Buttons
- use the same formControlName on all radios in the group
- you don't have to set the name attribute
- dynamically set value by doing [value]='...'
- Working with Select Lists
- dynamically set value by doing [value]='...'
- Working with Checkboxes
- Working with Numeric Inputs
- Working with Range Inputs
- Working with Textarea Elements
- Working with Date Values
- Summary
Mod 5: Validating Angular Reactive Forms
- Introduction
- Angular's Built-in Validators
- Adding Validation to FormControls
- when working with formbuilder, you set validators like this:
this.fb.group({ ... firstname: ['', Validators.required] ... });
- Displaying Validation Messages
- Handling Multiple Validators on a Single Field
- use case for a getter
- when you have a formcontrol with multiple validators, inspect the errors object to determine which validator is failing
- *ngIf='firstName.errors?.['required']' ..."
- Validating FormGroups and Forms
- Creating Custom Validators
- Passing Data to and from Custom Validators
- a custom validation is not required to returned a Boolean
- a demo of a custom validation that returns a string instead of a Boolean
- Summary
Mod 6: Creating Custom Controls and ControlValueAccessors
- Introduction
- Creating a Custom DateValueAccessor
- ControlValueAccessor as a directive on type input
- register the directive as an ng value provider
- Custom DateValueAccessor: Implementing writeValue()
- Custom DateValueAccessor: Handling Input Events
- Creating Custom Input Controls
- Binding a Custom Component to a FormControl
- a component as a ControlValueAccessor
- registerOnTouched is needed to know if the control has been touched for validation
- Summary
Mod 7: Dynamically Adding Form Elements
- Introduction
- Understanding FormArrays
- Adding FormArrays to a Form Model
- you bind a formArray with FormArrayName
- Dynamically Adding Form Elements
- looping formgroups inside of a formarray
- you may have to manually push all your formgorups into a formArray in ngOnInit
- even when using setValue, you will have to push empty formgroups
- Summary
Mod 8: Reacting to Changes
- Introduction
- Subscribing to Value Changes
- Reacting to Value Changes
- you can dynamically add a validator to a control using addValidators method
- to remove a validator, use removeValidators method
- use updateValueAndValidity method to notify angular to force validation check
- use distictUntilChnaged to prevent an infinite loop
- Adding Reactive Transformations
- example of how to temporarily remove a validaors and add it back
- Summary
Comments
Post a Comment