Saturday, February 16, 2019

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

Hey Guys ,

Today let's look at the following error :

'Can't bind to 'ngModel' since it isn't a known property of 'input"

This will come in case of two way binding.

The fix is simple , you need to import the forms module to your app module.

-----------app.module----------------------------

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

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

Import the two lines highlighted above and it should work fine .

View full source at here

No comments:

Post a Comment

ec2-user@ec2 Permission denied