Angular2: Error – Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’.

Standard

In order to implement two way binding in Angular2 application, you have to use [(ngModel)] binding in html code, but in case if you have receive below error:

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

screenshot_18

Solution:

You need to import the FormsModule package in your Angular module

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

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

@NgModule({
    imports: [
        //angular builtin module
        BrowserModule,
        FormsModule
    ],
    declarations: [
        AppComponent
    ],
    providers: [
    ],
    bootstrap: [
        AppComponent
    ]
})

export class AppModule {
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s