Author -  Sai gowtham

How to fix the can't bind to 'ngmodel' error in Angular

In this tutorial, we are going to learn about how to solve the Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’ error in an angular app.

When we use a ngModel directive inside the form input field, we will see this type of error in our terminal.

<input type="name" [(ngModel)]="name"/>

Error

ERROR in src/app/app.component.html:3:41 - error NG8002:
Can't bind to 'ngmodel' since it isn't a known property of 'input'.

<input type="name" [(ngmodel)]="name" />
                    ~~~~~~~~~~~~~~~~~~~

  src/app/app.component.ts:6:16
    6   templateUrl: './app.component.html',
                     ~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component AppComponent.

This occurs due to a FormsModule is not injected into the angular application.

Fixing the error

To fix this error, open your app.module.ts file and import the FormsModule from @angular/forms package and add it to the imports array.

app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    FormsModule  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Css Tutorials & Demos

How rotate an image continuously in CSS

In this demo, we are going to learn about how to rotate an image continuously using the css animations.

How to create a Instagram login Page

In this demo, i will show you how to create a instagram login page using html and css.

How to create a pulse animation in CSS

In this demo, i will show you how to create a pulse animation using css.

Creating a snowfall animation using css and JavaScript

In this demo, i will show you how to create a snow fall animation using css and JavaScript.

Top Udemy Courses

JavaScript - The Complete Guide 2023 (Beginner + Advanced)
JavaScript - The Complete Guide 2023 (Beginner + Advanced)
116,648 students enrolled
52 hours of video content
$14.99 FROM UDEMY
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
631,582 students enrolled
49 hours of video content
$24.99 FROM UDEMY
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
203,937 students enrolled
31.5 hours of video content
$14.99 FROM UDEMY