私のコンポーネントには、次を使用する単純な入力があります[(ngModel)]
:
<input type="text" [(ngModel)]="test" placeholder="foo" />
コンポーネントが表示されていない場合でも、アプリを起動すると次のエラーが発生します。
zone.js:461 未処理の Promise 拒否: テンプレート解析エラー: 'input' の既知のプロパティではないため、'ngModel' にバインドできません。
以下はcomponent.tsです:
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";
}
ベストアンサー1
はい、それです。app.module.ts ファイルに以下を追加しました:
import { FormsModule } from '@angular/forms';
[...]
@NgModule({
imports: [
[...]
FormsModule
],
[...]
})