【问题标题】:Expandable table (show more/less) [duplicate]可扩展表(显示更多/更少)[重复]
【发布时间】:2017-02-28 13:02:50
【问题描述】:

我环顾四周,但似乎没有找到我正在寻找的正确东西。我有一张很长的桌子,我想缩短一点。基本上我只想显示前 5 个条目并提供一个“显示更多”按钮。我知道如何实现它,但也许已经有一个 ng-component 了。

【问题讨论】:

标签: angular typescript angular-cli


【解决方案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>

【讨论】:

    【解决方案2】:
    <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);
    }
    

    【讨论】:

      猜你喜欢
      • 2014-08-14
      • 2021-12-20
      • 1970-01-01
      • 2020-06-18
      • 1970-01-01
      • 2018-07-27
      • 1970-01-01
      • 2019-05-17
      • 1970-01-01
      相关资源
      最近更新 更多