Skip to content

Template‑Driven Forms (FormsModule)

Template-Driven Forms rely mainly on Angular templates to manage form logic.
They use directives such as ngModel and require importing FormsModule.

import { NgModule } from "@angular/core";
import { FormsModule } from "@angular/forms";
@NgModule({
imports: [FormsModule],
})
export class AppModule {}
<form #userForm="ngForm">
<input name="username" ngModel placeholder="Username" />
<button type="submit">Submit</button>
</form>