abreneliere abreneliere - 8 months ago 925
AngularJS Question

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

I've got the following error when launching my Angular 2.0 app, even if the component is not displayed.

I have to comment out the so that my app works.

zone.js:461 Unhandled Promise rejection: Template parse errors:
Can't bind to 'ngModel' since it isn't a known property of 'input'. ("
<label>Créée le:</label>
<input type="text" [ERROR ->][(ngModel)]="test" placeholder="sdfqsdf" />
</div>"): InterventionDetails@4:28 ; Zone: <root> ; Task: Promise.then ; Value:

I'm looking at the Hero plucker but I don't see any difference.

Here is the component file:

import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Intervention } from '../../model/intervention';
import { OrigineFiche, TypeFiche } from '../../model/enums';

selector: 'intervention-details',
templateUrl: 'app/intervention/details/intervention.details.html',
styleUrls: ['app/intervention/details/intervention.details.css']

export class InterventionDetails
// l'intervention est passée en paramètre du composant
@Input() intervention: Intervention;

public test : string = "toto";


In order to be able to use two-way data binding for form inputs you need to import theFormsModule package in your Angular module. For more info see the Angular 2 official tutorial here and the official documentation for forms