启动我的 Angular 应用程序时出现以下错误,即使该组件未显示。
我必须注释掉,<input>以便我的应用程序正常工作。
<input>
zone.js:461 Unhandled Promise rejection: Template parse errors: Can't bind to 'ngModel' since it isn't a known property of 'input'. (" <div> <label>Created:</label> <input type="text" [ERROR ->][(ngModel)]="test" placeholder="foo" /> </div> </div>"): InterventionDetails@4:28 ; Zone: <root> ; Task: Promise.then ; Value:
我正在查看 Hero plunker,但我看不出与我的代码有任何区别。
这是组件文件:
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Intervention } from '../../model/intervention'; @Component({ selector: 'intervention-details', templateUrl: 'app/intervention/details/intervention.details.html', styleUrls: ['app/intervention/details/intervention.details.css'] }) export class InterventionDetails { @Input() intervention: Intervention; public test : string = "toto"; }
在app.module.ts文件中,我刚刚添加了:
import { FormsModule } from '@angular/forms'; [...] @NgModule({ imports: [ [...] FormsModule ], [...] })