NG-ZORRO范围选择器将开始日期设置为00:00:00,将结束日期设置为23:59:59。

huangapple go评论77阅读模式
英文:

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 [()]

huangapple
  • 本文由 发表于 2020年1月3日 17:31:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/59576043.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定