如何确定小时过滤器选择的角度

时间:2019-10-17 09:33:51

标签: javascript angular

当我在chrome中测试时,单选last 3 hourslast 12 hours会显示数据。但是,当我尝试在野生动物园中运行应用程序时,它不会显示数据。

这是代码。

*** list.component.ts ****

onChangeTime(event: any): void {
    const dateEnd = new Date(format(this.validateForm.value.datePickerEnd, ('YYYY-MM-DDTHH:mm:ss')));
    const hourSpan = new Date(subHours(dateEnd, event));
    let agoSelection: number = event;

    this.global.getData(`/conditions/?length=100&hours=${ agoSelection }`)
    .pipe(take(1))
      .subscribe((res: any) => {
        this.rowData = res['data'];
        this.rowData = this.rowData.filter((data: templogRecord) => {
          return !isBefore(data.date, hourSpan) && !isAfter(data.date, dateEnd);
        });
      });

    this.validateForm = this.formBuilder.group({
      datePickerStart: hourSpan,
      datePickerEnd: dateEnd,
    });
  }

list.component.html

<div nz-col class="gutter-row radio-group-selection" nzXXl="24">
          <div class="gutter-box">
            <nz-radio-group [(ngModel)]="radioValue" (ngModelChange)="onChangeTime($event)">
              <label nz-radio nzValue="3">Last 3 hours</label>
              <label nz-radio nzValue="12">Last 12 hours</label>
              <label nz-radio nzValue="240">Last 10 days</label>
              <label nz-radio nzValue="744">Last 31 days</label>
              <label nz-radio nzValue="2232">Last 3 months</label>
            </nz-radio-group>
          </div>
        </div>

0 个答案:

没有答案