Angular form control and form group

preview_player
Показать описание
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()
Рекомендации по теме
Комментарии
Автор

hey man, your are the best teacher in the world!

codewithfarzad
Автор

Angular is bloated and convoluted, but this video is pretty darn good... nice, clear explanation of *FormGroup* and *FormControl* concepts plus how to explore the detailed information they contain. 👍

DemPilafian
Автор

These videos are amazing! I've been surviving school because of you. Thank you! :)

bernadettealvarado
Автор

Your videos always provide a ton of excellent tips, thanks a million!!! :)

mirjana
Автор

Sir, please upload remaining videos.Especially Authentication and authorization and Globally error Handler if possible.

brajakisorpalei
Автор

sir, one of the important control is to upload the file through web form, kindly include this particular field in the form controls to add/modify and delete operation

sanjayrawat
Автор

Good explanation about formGroup and formControl. Awesome

rahulkamboj
Автор

Anyone looking for table with form control and group properties from 7:53 .
<table style="border: 1px solid blue;">
<tr style="border: 1px solid blue;">
<th style="padding:10px;border: 1px solid blues">Form Group</th>
<th style="padding:10px;border: 1px solid blue">FormControl (fullName) </th>
</tr>
<tr>
<td style="padding:10px;border: 1px solid blue">
Touched : {{emplyoeeForm.touched}}
<br /> dirty : {{emplyoeeForm.dirty}}
<br /> valid : {{emplyoeeForm.valid}}
<br /> Form Values : {{emplyoeeForm.value | json}}
</td>
<td style="padding:10px;border: 1px solid blue">
Touched :
<br /> dirty :

<br /> valid :
<br /> Full Name Value :
</td>
</tr>

</table>

saifumar
Автор

Good and Clear, Very helpful to students

jifri-hasanmon
Автор

Where can I get the code snippets for this? I checked the blogspot url. Didnt get anything

sriharsha
Автор

Dear Venkat,

Regarding the following html code, I would like to ask why the valid property value for both FormGroup and FormControl are true when we did not type anything in the Full Name field and Email field ?

Shouldn't the valid property value for both FormGroup and FormControl are suppose to be false when we did not type anything within the Full Name field and Email field ?

<table border="1">
<tr>
<th style="padding: 10px">FormGroup</th>
<th style="padding: 10px">FormControl (fullName)</th>
</tr>
<tr>
<td style="padding: 10px">
touched : {{ employeeForm.touched }}
<br/> dirty : {{ employeeForm.dirty }}
<br/> valid : {{ employeeForm.valid }}
<br/> Form Values : {{employeeForm.value | json}}
</td>
<td style="padding: 10px">
touched : {{ }}
<br/> dirty : {{ }}
<br/> valid : {{ }}
<br/> FullName Value :
</td>
</tr>
</table>


Best regards,
Edward

ymtan
Автор

Very interesting! Thanks a lot for that lesson!

elgrito
Автор

thanks you have very good explanation

rezokobaidze
Автор

nicely your presenting complex part.. thanks a lot!!!

vishal_taywade
Автор

Is this coding still same with latest Angular 11/12?

kirthiramakrishna
Автор

Sir, please suggest how can we do encryption and decryption in angular?

vaani_saini
Автор

Excellent videos! - Can you please post videos on Master and Detail grid - Thanks!

jumpatarun
Автор

Good explanation about formGroup and formControl, thank you...

VigneshwaranChandrasekaranA
Автор

Nice Video, Thank you for sharing #TapanDubey

TapanDubey
Автор

Sir I am learning Mean stack!!! am unable to understand that course anywhere!!! then one of my friends suggested ur You are Really amazing sir...!!! I want others parts like MongoDB, ExpressJs and sir hoe can I get that videos of Kindly please Rly to me sir as fast as u can becoz I have only one month to complete this plzzz plzzz SIR

krishnasaikrishnasai