啟動我的Angular應(yīng)用程序時,出現(xiàn)以下錯誤竣贪,即使組件未顯示军洼。
我必須注釋掉,以便我的應(yīng)用程序工作演怎。
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 plucker匕争,但是我沒有看到任何區(qū)別。
這是組件文件:
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
],
[...]
})
這樣就解決了。
angular歹叮、spring cloud 開源實(shí)戰(zhàn)項目源碼:https://gitee.com/xfdm/FCat
QQ群:549141844
代碼持續(xù)更新…