Angular forms work in two different ways, either as Template Driven Forms or as Reactive Forms - also sometimes called Model-Driven Forms
What Are Angular Template-Driven Forms?
Template-driven forms are driven by derivatives in the template. It first creates html-input-elements and then use directives like ngModel to bind their value to a component's variable.
Advantages and Disadvantages of Template-Driven Forms [1]
Ad: easier to create,
DIS: not friendly to unit testing, because testing requires the presence of a DOM.
Differences Between Template-Driven and Reactive Forms [1]
Template-driven forms use the FormsModule, while reactive forms use the ReactiveFormsModule.
Template-driven forms are asynchronous, while reactive forms are synchronous.
In template-driven forms, most of the interaction occurs in the template, while in reactive-driven forms, most of the interaction occurs in the component.
THESE ARE NOTES I TOOK FROM MY MICROSOFT FRONTEND DEVELOPMENT COURSE
Template Driven Form. This is the most basic way of constructing an Angular form, which involves rendering a form in a template with special properties that grant it Angular-specific form controls.
First we need to ensure that the FormsModule is imported into our Angular Module
Related articles
Angular Form - Reactive Form Form Validation Comparisons between Reactive Forms and Template Driven Forms
Angular forms work in two different ways, either as
Template Driven Forms
or asReactive Forms
- also sometimes calledModel-Driven Forms
What Are Angular Template-Driven Forms?
Template-driven forms are driven by derivatives in the template. It first creates html-input-elements and then use directives like
ngModel
to bind their value to a component's variable.Advantages and Disadvantages of Template-Driven Forms [1]
Ad
: easier to create,DIS
: not friendly tounit testing
, because testing requires the presence of aDOM
.Differences Between Template-Driven and Reactive Forms [1]
FormsModule
, while reactive forms use theReactiveFormsModule
.asynchronous
, while reactive forms aresynchronous
.template
, while in reactive-driven forms, most of the interaction occurs in thecomponent
.Click here for the demo
Template Driven Form
. This is the most basic way of constructing an Angular form, which involves rendering a form in a template with special properties that grant it Angular-specific form controls.References
[1] https://code.tutsplus.com/tutorials/angular-form-validation-with-reactive-and-template-driven-forms--cms-32131