All topics
Formsbeginner

Template-driven Forms

Explain how template-driven forms build the form model implicitly from directives in the template using FormsModule.

Template-driven forms are Angular's original forms approach, where the form's structure is implicitly derived from directives applied directly in the HTML template — ngModel, ngForm, required, and similar — rather than being explicitly constructed in the component class. FormsModule provides these directives, and under the hood, Angular automatically creates a FormGroup/FormControl model that mirrors your template structure, even though you never write that model yourself.

It's like verbally describing furniture placement to movers and trusting them to build the accurate floor plan themselves, versus handing them a pre-drawn blueprint (reactive forms) — faster to describe for a small room, riskier to rely on as the space gets more complex.

Key Concepts

1
This approach reads very naturally for simple forms: add ngModel to an input, give it a name attribute, and it's automatically registered as a control within the enclosing <form>'s implicit NgForm instance, which you can access via a template reference variable (#myForm="ngForm") to check overall validity or read the aggregated form value.
ngModelname<form>NgForm#myForm="ngForm"
2
The trade-off interviewers expect you to articulate clearly against reactive forms: template-driven forms are asynchronous under the hood (the form model isn't fully built until Angular finishes processing the template, so accessing it too early can be unreliable), harder to unit test since the model lives implicitly in the DOM rather than as a plain object in the component class, and considerably more awkward for dynamic forms, cross-field validation, or complex conditional logic — all things reactive forms handle far more directly.
3
A balanced interview answer positions template-driven forms as reasonable for genuinely simple cases (a two-field contact form, a basic settings toggle) but says most real-world, non-trivial forms in production Angular applications use the reactive forms API instead, precisely because of the testability and explicitness trade-offs.