Forms are very important part of an web application. Without forms we cannot insert data. In Angular JS, forms were very easy. Just use ngModel directive in form inputs and $scope in controller. But Angular has a different approach towards forms.

To work with Forms in Angular, Angular use FormsModule. We have seen an example of FormsModule in two way data binding. FormsModule can also helps in creating dynamic forms, form validation, custom validations and Forms testing.

Types of Forms in Angular?

  1. Template Driven Form
  2. Reactive Forms

FormsModule

FormsModule is required for both template driven forms and reactive forms.



Template Driven Forms

Template Driven Forms are like normal html forms with some feature of angular. The forms are create in template. We use Angular Directive for validation, two way data binding and change notification. This is the simplest way to create form in angular.

Advantages

Simple and quick to start. Best for simple forms.

Disadvantages

no dynamic controls and advance features.

Learn mode about Template Driven Forms


Reactive Forms

Reactive Forms are different. We have to build our own Model Objects with own validation rules. Forms binds data and sync to template.

Advantages

Got more controls for advance forms. Includes unit testing.

Disadvantages

not easy to build. Need knowledge of form model.

Learn mode about Reactive Forms