2017-08-23 14 views
0

コンソールでのエラー出力は1つ下にあります。従業員を追加するこのエラーは何ですか( 'ngModel'は 'input'の既知のプロパティではないためバインドできません)。

'ngModel'は 'input'の既知のプロパティではないため、バインドできません。 (」 ] [(ngModel)] = "model.name" プレースホルダ= "あなたのお名前を入力します">

here is the error image

以下は

<div class = "container"> 
<h1>{{title}}</h1> 
<h2>Add Employee:</h2> 
<form class="form-horizontal"> 
<div class="form-group"> 
<label class="control-label col-sm-2" for="name">Name:</label> 
<div class="col-sm-10"> 
<input type="text" class="form-control" id="name" 
name="name" [(ngModel)]="model.name" 
placeholder="Enter Your Name"> 
</div> 
</div> 
<div class="form-group"> 
<label class="control-label col-sm-2" for="position">Position:</label> 
<div class="col-sm-10"> 
<input type="text" class="form-control" id="position" 
name="position" [(ngModel)]="model.position" 
placeholder="Enter your position"> 

</div> 
</div> 
<div class="form-group"> 
<label class="control-label col-sm-2" for="salary">Salary:</label> 
<div class="col-sm-10"> 
<input type="text" class="form-control" id="salary" 
name="salary" [(ngModel)]="model.salary" 
placeholder="Enter Salary"> 
</div> 
</div> 
<div class="form-group"> 
<div class="col-sm-offset-2 col-sm-10"> 
<button type="submit" class="btn btn-default" click)="addEmployee">Add 
Employee</button> 
</div> 
</div> 
</form> 
<h2>Employee Details</h2> 
<table class="table table-bordered"> 
<thead> 
<tr> 
<th width=400>Name</th> 
<th width=400>Position</th> 
<th width=400>Salary</th> 
<th width=200>Actions</th> 
</tr> 
</thead> 
enter code here 
<tbody> 
<tr *ngFor="let employee of employees; let i=index"> 
<td>{{employee.name}}</td> 
<td>{{employee.position}}</td> 
<td>{{employee.salary}}</td> 
<td><a class="btn btn-danger">Delete</a></td> 
</tr></tbody></table></div> 
+1

からimport {FormsModule}を追加して問題を解決しました。 '@ angular/forms'; @NgModule({ declaratイオン:[ AppComponent ]、 インポート:[ BrowserModule 、app.module.ts内のFormsModule –

答えて

0

はで私の問題を解決し、それのコードです@Angel/formsからimport {FormsModule}を追加し、@NgModule({宣言:[AppComponent]、import:[BrowserModule、FormsModule] in app.module.ts

関連する問題