What are Forms in Angular?

Forms are very integral and essential building blocks of every apps. Forms allows us to gather information and data from user. Good way to interact with users and almost all websites will need forms in some or other way

Common form examples we can see are:

  • login
  • register
  • forget password
  • checkout form
  • contact form
  • feedback form etc.

Angular Form Types:

  • Template Driven Forms
  • Reactive Forms (Dynamic Forms)

Angular Template Driven Form:

  • Easy to use
  • Template driven forms are simple and straightforward
  • All the validations, form elements are all defined in the template file
  • We will need to import FormsModule in app module to work with template driven forms

Angular Reactive/Dynamic Form:

  • All the form elements, user interactions and validations are handled in the component class.
  • We will make use of angular built in formGroup and formControl.
  • Can control better data binding.
  • Exclusive define custom regular expression patterns of error handling.
  • We will need to import ReactiveFormsModule in our app module.
  • Very flexible and allows users to define, develop complex requirements of forms.
  • More logic in the component class and less in HTML mark up itself.