Angular2 – How to create a simple table

Here’s an example of simple table that will redirect you to details on row click:

<table class="table table-hover">
    <thead>
        <tr>
            <td>Id</td>
            <td>Title</td>
            <td>Amount</td>
        </tr>
    </thead>
    <tbody>
        <tr *ngFor="let transfer of transfers" [routerLink]="['/transfer']" [queryParams]="{ id: transfer.id }">
            <td>{{transfer.id}}</td>
            <td>{{transfer.title}}</td>
            <td>{{transfer.amount}}</td>
        </tr>
    </tbody>
</table> 

I assumed you’re working with transfers array and redirect based on id.

Leave a Comment