To fix this error, you just need to import ReactiveFormsModule
from @angular/forms
in your module.
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; port { FormsModule, ReactiveFormsModule } from '@angular/forms'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, ReactiveFormsModule, FormsModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
You can even import both the ReactiveFormsModule
and FormsModule
into your app if you need to support both Template Forms and Reactive Forms in the same Angular application or feature.
Once you’ve updated your module file to include the ReactiveFormsModule
, your app and new form should work.