2

我想读取用户选择的范围之间的数据,但我无法获得所选的开始日期和结束日期。尽管在控制台中我可以立即看到它,但不知道我们如何获取这些日期并执行查询。还获取所选范围之间的日期。例如:下面:应该返回 betweendates = [7/11/19 , 8/11/19]

这里控制台日志

<input type="text" matInput
    ngxDaterangepickerMd
    [locale]="{applyLabel: 'ok', format: 'DD-MM-YYYY'}"
    startKey="startDate"
    endKey="endDate"
    [(ngModel)]="selectedDaterange"
    name="daterange"
    (change)= 'selectDateRange()'
    placeholder="choose date"/>  
selectDateRange() {
    console.log(moment().format());
    console.log(this.selectedDaterange);
}

4

1 回答 1

1

You can use the following to get the javascript Date object

this.selectedDaterange.startDate.toDate();
this.selectedDaterange.endDate.toDate();

Check the following documentation for all the examples on how you can use moment

https://momentjs.com/docs/#/displaying/as-javascript-date/

于 2019-11-02T07:33:11.593 回答