DEV Community

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

Posted on

25

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.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay