Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’

Angular

Are you looking for a quick solution for Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’ error?

Solution 1:

Import FormsModule to your app.module.ts or to your component module if you are lazy loading.

Solution 2:

Import both FormsModule and ReactiveFormsModule to your app.module.ts or to your component module if you are lazy loading.

Solution 3:

Import the required modules in the order like:
imports: [BrowserModule, FormsModule, ReactiveFormsModule]

See the solution 2 code example.

Solution 4:

Do you still have the error after trying the above three solutions? The Angular project might not compile because of another error. See the console and fix the other errors if you have.
For example, You are missing to import CommonModule before the FormsModule and your project does not compile which throws errors for CommonModule and FormsModule.

Explanation:

NgModule is the directive of FormsModule. The directive is unknown to the element if you do not import the FormsModule. You have to import the module in app.module.ts or for the component module if you are lazy loading. It still throws an error if you import it in the app.module.ts but not for the module of the component if you have one.

You should be able to solve the problem with the above solutions. Please leave a comment if you cannot solve Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’ Angular error.