How to fix error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.

Problem:

When trying to load your Angular app in ng serve you see an error message like

ngmodel_formsmodule_fix.txt
error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.

2     <input type="text" pInputText [(ngModel)]="text"/>
                                    ~~~~~~~~~~~~~~~~~~~~~

Solution

You have not loaded FormsModule in your app.module.ts.

Import it using

example.ts
import {FormsModule} from '@angular/forms';

and load it by appending

example.ts
FormsModule,

to imports: [...] in app.module.ts , for example:

example.ts
imports: [
  BrowserModule,
  AppRoutingModule,
  HttpClientModule,
  InputTextModule,
  FormsModule,
],

Check out similar posts by category: Angular, Javascript