【问题标题】:Is it possible to create a duplicate of a table with same continuous items?是否可以创建具有相同连续项目的表的副本?
【发布时间】:2021-09-27 05:43:23
【问题描述】:

我想创建两个表,包含相同的数组,但第二个表包含第一个表的连续项。

我在项目中使用 Angular v.11 和 Clarity。该表是用以下方式构建的:

<clr-dg-row *clrDgItems="let employee of employees" [clrDgItem]="employee">
    <clr-dg-cell>{{ employee.employeeId }}</clr-dg-cell>
</clr-dg-row>

[示例] 第一个表有 5 行不同的水果,第二个数组有 5 行数组中的下一个水果。

然后您可以单击表格底部的下一张幻灯片,以获得 10 个下一个水果。
也就是说,水果 11-20 将向用户展示。

如下图:

Two Tables with continuous items

【问题讨论】:

    标签: javascript html arrays json angular


    【解决方案1】:

    你可以这样做:

    //First table
    *clrDgItems="let employee of employees.filter((_,i) => return i <= firstTableMaxIndex)"
    
    //Secondtable
    *clrDgItems="let employee of employees.filter((_,i) => return i > firstTableMaxIndex && i <= secondTableMaxIndex)"
    

    然后,当您对表格进行分页时,您可以更改 firstTableMaxIndexsecondTableMaxIndex 的值。但是,要使反应性在分页中按预期工作,您需要使用 custom pipe 而不是像上面那样过滤数组内联。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-18
      • 2011-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-01
      相关资源
      最近更新 更多