如何遍历日期时间数组并仅显示当前周记录

How to Iterate through array of Day Time and display only current week record

 ng-repeat="day in task.DailyWorks | limitTo : weekdays.length: weekStart"

我正在尝试遍历 table 列中的日常工作记录,我想第一次显示当前周记录。然后取决于用户单击上一周或下周按钮,它将更改记录。

在 Angular 2+ 中,您可以使用 *ngFor 进行迭代。自 Angular 7 起支持 一年中的第几周 每月第几周 的 DatePipes。

As Angular docs of DatePipe says:

Week of year: w

Week of month: W

An example at stackblitz

显示一个月中的第几周:

<h3>Number of week in month: </h3>
<div *ngFor = "let title of data">     
    {{title.CREATE_TS | date:'dd/mm/yyyy'}}
    <br/> Number of week in month is
    {{title.CREATE_TS | date:'W'}}
</div>

显示一年中的第几周:

<div *ngFor = "let title of data">
    {{title.CREATE_TS | date:'dd/mm/yyyy'}}
    <br/> Number of week in year is
    {{title.CREATE_TS | date:'w'}}  
</div>

打字稿:

data = [
    {
      CREATE_TS: "2018-08-15 17:17:30.0",
      Key1: "Val1",
      Key2: "Val2",
    },
    {
      CREATE_TS: "2018-08-15 17:25:30.0",
      Key1: "Val1",
      Key2: "Val2",
    },
    {
      CREATE_TS: "2018-08-15 17:28:30.0",
      Key1: "Val1",
      Key2: "Val2",
    }
  ]
}