[英]How to display only a range between 2 different months in primeng calendar (p-calendar)?
I'm trying to display a range between 2 months in p-calendar without success for example I would like to display dates only between the middle of a month untile the middle of next month.我试图在 p-calendar 中显示 2 个月之间的范围,但没有成功,例如,我只想在月中到下个月中显示日期。 I would like to do it using reactiveForm with formcontrol, but a solution with ngModel would be in any case appreciated.我想使用带有formcontrol的reactiveForm来做到这一点,但无论如何,使用ngModel的解决方案都会受到赞赏。
I am confused what you are asking, but this is a try.我很困惑你在问什么,但这是一个尝试。 This displays two months allowing for selection of a date range:这显示两个月,允许选择日期范围:
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() {
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.