メインページにテーブルを表示するコードがあり、テーブルの各行に2つのボタンがあります。 "編集ボタンをクリックすると、モーダルが開きます。今私の質問は、私は特定の従業員のボタンをクリックして "従業員のID"を渡す必要があることです。これどうやってするの?だから私はid: "101"のempoyeeを持っていて、この "101"をボタンのクリックの編集モーダルコンポーネントに渡す方法を教えて、その従業員のテキストボックスにテキストボックスでデータを入力できるようにします私のモーダルですか?おそらく、この要素であるOne Componentから別のComponentへデータを送信する方法ボタン2をクリックして表示する方法
@Component({
selector: 'ops-employee',
pipes: [],
styles: [],
template: `
<ops-addmodal [(open)]="addEmployeeOpen" (check)="updateEmployeeList($event)"></ops-addmodal>
<ops-editmodal [(open)]="editEmployeeOpen" [data]="editId" (check)="editEmployeeList($event)">
</ops-editmodal>
<div class="col-md-8 col-md-offset-2">
<h1> Employee Info </h1>
<hr>
<button class="btn btn-lg btn-primary" (click)="addEmployee()">Add</button>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Role</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr *ngFor = "#employee of employeeDetails">
<td>{{employee.empName}}</td>
<td>{{employee.empAge}}</td>
<td>{{employee.empRole}}</td>
<td>
<button class="btn btn-sm btn-default" (click)="editEmployee(employee.empId)">Edit</button>
<button class="btn btn-sm btn-danger" (click)="deleteEmployee(employee.empId)">Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
`,
directives: [AddEmployeeModalComponent, EditEmployeeModalComponent, ModalComponent]
})
ありがとうございます!偉大なアイデア...私は@ViewChildの観点から考えようとしていましたが、混乱しました。 – Kashyap