无法绑定到'ngModel',因为它不是'input'的已知属性 [英] Can't bind to 'ngModel' since it isn't a known property of 'input'
本文介绍了无法绑定到'ngModel',因为它不是'input'的已知属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
启动Angular应用程序时出现以下错误,即使未显示该组件也是如此。
I've got the following error when launching my Angular 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'. ("
<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,但我没有看到任何差异。
I'm looking at the Hero plunker but I don't see any difference.
这是组件文件:
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,我刚刚添加:
Yes that's it, in the app.module.ts, I just added :
import { FormsModule } from '@angular/forms';
[...]
@NgModule({
imports: [
[...]
FormsModule
],
[...]
})
这篇关于无法绑定到'ngModel',因为它不是'input'的已知属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文