我在表中有一些数据绑定,单击任何特定的我想将当前单击的对象显示更多相关数据到另一个组件(子组件)
例如我从此链接获取的数据: http: //jsonplaceholder.typicode.com/users
HTML 代码:
<table>
<thead>
<th>
Id
</th>
<th>
name
</th>
<th>
username
</th>
<th>
email
</th>
<th>
street
</th>
<th>
suite
</th>
<th>
zipcode
</th>
<th>
phone
</th>
<th>
website
</th>
</thead>
<tbody>
<tr *ngFor="let data of httpdata">
<td>{{data.id}}
</td>
<td>{{data.name}}
</td>
<td>{{data.username}}
</td>
<td>{{data.email}}
</td>
<td>{{data.address.street}}
</td>
<td>{{data.address.city}}
</td>
<td>{{data.address.suite}}
</td>
<td>{{data.address.zipcode}}
</td>
<td>{{data.phone}}
</td>
<td>{{data.website}}
</td>
<td>
<a routerLink="/conflict-details/conflict" (click)="onSelect(data)">Go to
</a>
</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
如果您看到表中有一个“转到”按钮,当我单击任何特定数据时,它应该向我显示有关当前单击的完整信息,但在我的情况下,当我单击“转到”以获取特定数据时,我想将数据绑定到另一个组件中所有 td 数据都应显示在新组件(子组件)中。
简单我想跟踪子组件中选定数据的单击事件。并且该表在父组件中呈现。
附件是我的数据表。