如何在黄金时段日历(p日历)中仅显示2个不同月份之间的范围



我试图在p日历中显示2个月之间的范围,但没有成功。例如,我希望只显示月中到下月中之间的日期。我想使用带有formcontrol的reactiveForm来完成这项工作,但无论如何都会感谢使用ngModel的解决方案。

我不明白你在问什么,但这只是一次尝试。这显示两个月,允许选择日期范围:

import { Component, ViewChild } from '@angular/core';
import { Calendar } from 'primeng/calendar';
@Component({
selector: 'app-root',
template: `
<div class="p-fluid p-grid p-formgrid">
<div class="p-field p-col-12 p-md-4">
<label for="multiplemonths">Multiple Months</label>
<p-calendar #rangeCal [(ngModel)]="rangeDates" [numberOfMonths]='2'
selectionMode="range" inputId="multiplemonths"></p-calendar>
</div>
</div>`
})
export class AppComponent { 
@ViewChild( 'rangeCal' ) rangeCal: Calendar;
rangeDates: Date[];
ngOnInit() {
}
}

最新更新