我一直在尝试为我的数据设计一个日期范围过滤器,并制作了一个测试函数来将变量更改为开始日期和结束日期。该代码在直接调用时显示正确的日期,但是在打印变量时,它不能正确打印。
组件.html:
<div class="search">
<input type="text" matInput
id = 'calander'
ngxDaterangepickerMd
[locale]="{
cancelLabel: 'Cancel',
applyLabel: 'Okay',
clearLabel: 'Clear',
format: 'YYYY/MM/DD'
}"
startKey="start"
endKey="end"
[(ngModel)]="selected"
name="daterange"
(ngModelChange)="doSomething($event)"/>
<button class="ripple" type="submit" ></button>
</div>
组件.ts:
startDate: Moment;
endDate: Moment;
doSomething(event){
console.log(event) // input value is logged
alert(event.start);
this.startDate = event.start;
this.endDate = event.end;
alert('start: ' + this.startDate + '\nend: ' + this.endDate);
}