Skip to content

Instantly share code, notes, and snippets.

@P1xt
Created March 14, 2017 02:55
Show Gist options
  • Save P1xt/7f95b00da3a5346dbd6d8a9e2213ad58 to your computer and use it in GitHub Desktop.
Save P1xt/7f95b00da3a5346dbd6d8a9e2213ad58 to your computer and use it in GitHub Desktop.
Angular 2 *ngFor loop illustrating looping through an array of objects to populate an html table
<section class="leader-table">
<h2>All Time Leaderboard</h2>
<table class="table-hover table-striped">
<thead>
<tr>
<th colspan="2">Camper</th>
<th>Points in past 30 days</th>
<th>All time Points</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let camper of campers">
<td cellpadding="0" cellspacing="0" class="avatar-cell"><img class="avatar" src="{{camper.img}}" alt="camper avatar"></td>
<td>{{camper.username}}</td>
<td>{{camper.recent}}</td>
<td>{{camper.alltime}}</td>
</tr>
</tbody>
</table>
</section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment