In this article, we will present how to solve the Angular problem: can't bind to 'ngModel' since it isn't a known property of 'input'.
2. Solve can't bind to
ngModel since it isn't a known property of the
First, let's create an Angular project where the specified problem occurs.
Using Angular CLI create a new
As you can see we use two-way data binding in app.component.html:
[(ngModel)]="test" and that causes an error:
To solve this issue you need to import the
FormsModule package into your Angular module:
And, that's it. The application should run without any issue now:
In this short, article we presented how to solve can't bind to ngModel since it isn't a known property of input issue. In most cases to solve this kind of error all you need to do is to import
FormsModule in a module where you use binding on
input elements or in the main application module