0
コンソールでのエラー出力は1つ下にあります。従業員を追加するこのエラーは何ですか( 'ngModel'は 'input'の既知のプロパティではないためバインドできません)。
'ngModel'は 'input'の既知のプロパティではないため、バインドできません。 (」 ] [(ngModel)] = "model.name" プレースホルダ= "あなたのお名前を入力します">
以下は
<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>
からimport {FormsModule}を追加して問題を解決しました。 '@ angular/forms'; @NgModule({ declaratイオン:[ AppComponent ]、 インポート:[ BrowserModule 、app.module.ts内のFormsModule –