Mateusz Mateusz - 1 year ago 100
TypeScript Question

Angular 2 - get last 5 records from database

how can I get last 5 records from database?


<table class="table table-striped table-bordered">
<th>Logging in is completed?</th>
<tr *ngFor="let log of logs">

<td >{{}}</td>
<td >{{log.isCompleted}}</td>



With above code I get all records. I would like to do something similar to:

for(int i=logs.length();i>logs.length()-5;i--)

Answer Source

I did it that way:

  <tr *ngFor="let log of logs; let i =index">

                    <td *ngIf ="i>=logs.length -5">{{}}</td>
                    <td * ngIf="i>=logs.length -5">{{log.isCompleted}}</td>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download