//... imports
@NgModule({
declarations: [
AppComponent,
YourFormComponent // <-- Your form component
],
imports: [
BrowserModule,
FormsModule // <-- For template-driven forms
],
providers: [],
bootstrap: [ AppComponent ]
})
export class AppModule { }
form:not([ngNoForm]):not([formGroup]),ngForm,[ngForm]
<form #f="ngForm" (ngSubmit)="onSubmit(f.value)">
<label for="name">First name</label>
<input id="name" name="name" ngModel>
</form>
<form #f="ngForm" (ngSubmit)="onSubmit(f.value)">
<label for="name">First name</label>
<input id="name" name="name" ngModel>
</form>
//... imports
@NgModule({
declarations: [
AppComponent,
YourFormComponent // <-- Your form component
],
imports: [
BrowserModule,
ReactiveFormsModule // <-- For reactive forms
],
providers: [],
bootstrap: [ AppComponent ]
})
export class AppModule { }
<form [formGroup]="form" (ngSubmit)="onSubmit(form.value)">
<label for="firstName">First name</label>
<input id="firstName" formControlName="firstName">
</form>