0

I was looking a bit around, but I seem not to find the right thing I was looking for. I'm having a quite long table, which I would like to shorten a bit. Basically I'd like display only the first 5 entries and offer a 'show more'-button. I know how to implement it, but maybe there is a ng-component already out there.

tschaka1904
  • 1,303
  • 2
  • 17
  • 39

2 Answers2

1
<button (click)="showAll = !showAll">
    <span *ngIf="showAll == false" >show all</button></span>
    <span *ngIf="showAll == true">show all</button></span>
</button>
<table>
    <tr *ngFor="let item of items, let i = index" *ngIf="showAll(i) === true">

    </tr>
</table>

showAll : boolean = false;
showAll(index : number){
    return this.showAll ? true : ((index > 5) ? false : true);
}
Yoav Schniederman
  • 5,253
  • 3
  • 28
  • 32
1
show = someNumber; // 5

<tr *ngFor="let item of items |slice:0:showlet i=index">
  <div *ngIf="i == someNumber && show" (click)="show = items.length"></div>
</tr>
Yoav Schniederman
  • 5,253
  • 3
  • 28
  • 32