Oudstand Oudstand - 9 months ago 133
TypeScript Question

Unhandled Promise rejection: Template parse errors: Can't bind to 'ngModel' since it isn't a known property of 'input'

I always get the error Can't bind to 'ngModel' since it isn't a known property of 'input'. if I try to use something like this:

<div *ngIf="guide" class="form-group">
<label for="guideName">Name: </label>
<input class="form-control" name="guideName" [(ngModel)]="test" required id="guideName">

<button (click)="saveGuide(guide)"></button>

My app.module.ts looks like this:

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

import {GuideModule} from "./guide/guide.module";

imports: [BrowserModule, FormsModule, routing, GuideModule],
declarations: [AppComponent],
bootstrap: [AppComponent]

export class AppModule {}

In my package.json I have:

"dependencies": {
"@angular/forms": "^2.1.2",

My systemjs.config.ts:

(function (global) {
paths: {
// paths serve as alias
'npm:': 'node_modules/'
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
"@angular/forms": "node_modules/@angular/forms/bundles/forms.umd.js",
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
rxjs: {
defaultExtension: 'js'

Answer Source

You are getting this error because guide-details.component.ts is not part of AppModule where you imported FormsModule (NgModel directive is part of FormsModule). You have to import FormsModule in module in which guide-details.component.ts is declared or move guide-details.component.ts to AppModule's declarations.