英文:
NG-ZORRO range-picker set hour for start date at 00:00:00 and for end date at 23:59:59
问题
在这个示例中,我该如何将开始日期和结束日期的小时设置为分别为00:00:00和23:59:59?
我不想手动像这样设置:
export class MyComponent {
dateRange = [];
onChange(result): void {
this.dateRange[0].setHours(0,0,0);
this.dateRange[1].setHours(23,59,59);
}
}
英文:
Having this example, how can I set the hours of the start date and end date to 00:00:00 and 23:59:59 respectively?
I don't really want to set this manually like this:
export class MyComponent {
dateRange = [];
onChange(result): void {
this.dateRange[0].setHours(0,0,0);
this.dateRange[1].setHours(23,59,59);
}
}
答案1
得分: 1
如果它纯粹是可视化的,您可以使用管道代替(https://angular.io/guide/pipes)。
编辑:一个函数用于多个编辑器
您可以在每个nzOnCalendarChange
日期范围上都使用一个onChange(result)
调用。然后,不要改变this.dateRange
,而是改变result
,因为它应该是小部件的date[]。
只要它是一个双向绑定[()]
,改变result
也会导致绑定对象发生变化。
英文:
If it is purely visual you could use pipes instead (https://angular.io/guide/pipes).
EDIT: one function for multiple editors
You can use one onChange(result)
call with every nzOnCalendarChange
date range you have. Then instead of changing the this.dateRange
change result
as it should be the date[] of the widget.
Changing result
will also result in the binding object to change as long as it is a 2 way bind [()]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论