filmov
tv
Angular form control and form group
Показать описание
In this video we will discuss FormControl and FormGroup classes
Text version of the video
Healthy diet is very important for both body and mind. We want to inspire you to cook and eat healthy. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking.
Slides
Angular 6 Tutorial
Angular 6 Tutorial Text Articles & Slides
Angular, JavaScript, jQuery, Dot Net & SQL Playlists
When working with reactive forms we create instances of FormControl and FormGroup classes to create a form model.
To bind an HTML form tag in the template to the FromGroup instance in the component class, we use formGroup directive
To bind an HTML input element in the template to the FormControl instance in the component class, we use formControlName directive
formGroup and formControlName directives are provided by the ReactiveFormsModule
Both FormControl and FormGroup classes inherit from AbstractControl base class
The AbstractControl class has properties that help us track both FormControl and FormGroup value and state
The following are some of the useful properties provided by the AbstractControl class
value
errors
valid
invalid
dirty
pristine
touched
untouched
FormControl instance tracks the value and state of the individual html element it is associated with
FormGroup instance tracks the value and state of all the form controls in it's group
To see the form model we created using FormGroup and FormControl classes, log the employeeForm to the console.
onSubmit(): void {
}
To access a FormControl in a FormGroup, we can use one of the following 2 ways.
Note: This same code works, both in the template and component class.
In addition to these properties, AbstractControl also provides the following methods. In our upcoming videos we will use these properties and methods for form validation and working with data.
setValidators()
clearValidators()
updateValueAndValidity()
setValue()
patchValue()
Reset()
Text version of the video
Healthy diet is very important for both body and mind. We want to inspire you to cook and eat healthy. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking.
Slides
Angular 6 Tutorial
Angular 6 Tutorial Text Articles & Slides
Angular, JavaScript, jQuery, Dot Net & SQL Playlists
When working with reactive forms we create instances of FormControl and FormGroup classes to create a form model.
To bind an HTML form tag in the template to the FromGroup instance in the component class, we use formGroup directive
To bind an HTML input element in the template to the FormControl instance in the component class, we use formControlName directive
formGroup and formControlName directives are provided by the ReactiveFormsModule
Both FormControl and FormGroup classes inherit from AbstractControl base class
The AbstractControl class has properties that help us track both FormControl and FormGroup value and state
The following are some of the useful properties provided by the AbstractControl class
value
errors
valid
invalid
dirty
pristine
touched
untouched
FormControl instance tracks the value and state of the individual html element it is associated with
FormGroup instance tracks the value and state of all the form controls in it's group
To see the form model we created using FormGroup and FormControl classes, log the employeeForm to the console.
onSubmit(): void {
}
To access a FormControl in a FormGroup, we can use one of the following 2 ways.
Note: This same code works, both in the template and component class.
In addition to these properties, AbstractControl also provides the following methods. In our upcoming videos we will use these properties and methods for form validation and working with data.
setValidators()
clearValidators()
updateValueAndValidity()
setValue()
patchValue()
Reset()
Комментарии