如何始终在今天的日期打开 PrimeNg 的 p-calendar
How to always open PrimeNg's p-calendar on today's date
''我在 Angular 应用程序中使用 PrimeNg 的日历。我正在使用多个 selectionMode 并将日历绑定到数据库中的日期数组。日历从数据库范围内的最新日期开始,但我希望它始终从今天的日期开始,然后用户可以前后导航以查看先前从数据库中选择的日期。我设置了 defaultDate 但它没有任何区别。
请帮忙。
谢谢,
我的html:
<p-calendar [(ngModel)]="myDates" selectionMode="multiple" [inline]="inline" selectOtherMonths="true" [defaultDate]="defaultDate"></p-calendar>
我的代码:
public myDates: Date[] = [];
public defaultDate: Date = new Date();
constructor()
{
this.myDates.push(new Date('01-01-2017'));
this.myDates.push(new Date('01-02-2017'));
this.myDates.push(new Date('01-07-2017'));
}
对我有用!
在html
<p-calendar [(ngModel)]="date1"></p-calendar>
在 TS
export class CalendarDemo {
date1: string;
ngOnInit() {
let today = new Date();
this.date1 = today.getMonth() + '/' + today.getDate() + '/' + today.getFullYear();
}
}
HTML
[minDate]="minDateValue"
Ts
this.minDateValue = 新日期();
''我在 Angular 应用程序中使用 PrimeNg 的日历。我正在使用多个 selectionMode 并将日历绑定到数据库中的日期数组。日历从数据库范围内的最新日期开始,但我希望它始终从今天的日期开始,然后用户可以前后导航以查看先前从数据库中选择的日期。我设置了 defaultDate 但它没有任何区别。
请帮忙。
谢谢,
我的html:
<p-calendar [(ngModel)]="myDates" selectionMode="multiple" [inline]="inline" selectOtherMonths="true" [defaultDate]="defaultDate"></p-calendar>
我的代码:
public myDates: Date[] = [];
public defaultDate: Date = new Date();
constructor()
{
this.myDates.push(new Date('01-01-2017'));
this.myDates.push(new Date('01-02-2017'));
this.myDates.push(new Date('01-07-2017'));
}
对我有用!
在html
<p-calendar [(ngModel)]="date1"></p-calendar>
在 TS
export class CalendarDemo {
date1: string;
ngOnInit() {
let today = new Date();
this.date1 = today.getMonth() + '/' + today.getDate() + '/' + today.getFullYear();
}
}
HTML
[minDate]="minDateValue"
Ts
this.minDateValue = 新日期();