DEV Community

Kafeel Ahmad (kaf shekh)
Kafeel Ahmad (kaf shekh)

Posted on

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

This error occurs when you try to use ngModel directive in your component’s template but have not imported the FormsModule in your app module or the component’s module.
To solve this error, you need to import the FormsModule in your app module or the component’s module. Here is an example:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms'; // Import the FormsModule

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule // Add FormsModule to the imports array
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
Enter fullscreen mode Exit fullscreen mode

Once you have imported the FormsModule, you should no longer receive this error. For more information, you can refer to this Github issue: https://github.com/angular/angular/issues/13768

For any question please comment.

Top comments (0)