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
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
import {FormsModule} from '@angular/forms';
and load it by appending
FormsModule,
to imports: [...]
in app.module.ts
, for example:
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
InputTextModule,
FormsModule,
],