Control classes and directive
- In angular we have two classes to keep track of the state of input fields and their validity
Formcontrol
which represents one input field- When we apply
ngModel
directive on the input field angular automatically creates a formcontrol object and associates that with the input field Formgroup
which represents a group of input fields- Used to represent a entire form and optionally groups within the form
ngForm
is applied automatically to all form elements and creates a form group object and associates with the form. It tracks the state changes of form and their validity.- When you have complex form with mulitple subgroups, you can optionally apply
ngModelGroup
directive on subgroup creates a form group object for that sub group - ngForm exposes output property
ngSubmit
which is used to handle submit events of form,ngModelGroup
doesn't