EmployeeListComponent
は、従業員のリストと部門名を入力として受け取ります。ユーザーが従業員を削除または追加しようとすると、コンポーネントによって対応する出力がトリガーされます。また、このコンポーネントはビジネス計算を実装する calculate
メソッドも定義します。
EmployeeListComponent
のテンプレートは次のとおりです。
<h1 title="Department">{{ department }}</h1>
<mat-form-field>
<input placeholder="Enter name here" matinput="" type="text" [(ngmodel)]="label" (keydown)="handleKey($event)">
</mat-form-field>
<mat-list>
<mat-list-item *ngfor="let item of data">
<h3 matline="" title="Name">
{{ item.label }}
</h3>
<md-chip title="Score" class="mat-chip mat-primary mat-chip-selected" color="primary" selected="true">
{{ calculate(item.num) }}
</md-chip>
</mat-list-item>
</mat-list>