打字稿-仅显示今天的记录

时间:2018-08-15 11:41:51

标签: html angular typescript angular6

一个简单的问题:如何显示具有今天日期的记录列表? 我的HTML:

<table class='table hovertable'>
        <tbody class="mytable">
          <tr *ngFor="let timeRecord of timeRecords">
            <th>
              {{timeRecord.date | date:'dd.\u00A0'}}{{timeRecord.date | date:'MMMM' | convertToSlovakMonthsPipe}}
            </th>
            <td>
              {{timeRecord.duration}}&nbsp;h
            </td>
            <td>
              {{timeRecord.allocation}}
            </td>
            <td>
              {{timeRecord.comment}}
            </td>
          </tr>
        </tbody>
      </table>

和获取所有记录的打字稿:

getTimeRecords() {
    this.timeRecordService.getTimeRecords()
      .subscribe(
        (time: ITimeRecord[]) => {
          this.timeRecords = time;
        }
      )
  }

1 个答案:

答案 0 :(得分:0)

this.timeRecords = time.filter(t => t.getTime() == Date.now().getTime() );