I want to make each row of a table clickable in Angular 2. However, only the parts of the cell that contain data are clickable. i.e. if one cell contains more data than another, and so has a greater height, the empty bit of the smaller cell is not clickable.
For example, in the page below the first cell is only clickable on the line containing the name, whereas the entirety of the second cell is clickable
<table>
<thead></thead>
<tbody>
<tr *ngFor="let item of items" routerLink="/otherpage/{{item.Id}}">
<td>{{item.name}}</td>
<td>
<ul>
<li *ngFor="let detail of item.details">
{{detail}}
</li>
</ul>
</td>
</tr>
</tbody>
</table>
I've fixed the routerLink
code for you.
<table>
<thead></thead>
<tbody>
<tr class="clickable" *ngFor="let item of items" [routerLink]="['/otherpage/', item.Id]">
<td>{{item.name}}</td>
<td>
<ul>
<li *ngFor="let detail of item.details">
{{detail}}
</li>
</ul>
</td>
</tr>
</tbody>
</table>
You need to add CSS for the animation.
clickable {
cursor: pointer;
}
This will make the entire <tr></tr>
clickable with the cursor animation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With