我想更改 gx-daterangepicker-material 的默认值,例如昨天到最后 7 天,有人知道如何设置吗?
代码:
export class CustomRangesComponent implements OnInit {
selected: any;
alwaysShowCalendars: boolean;
ranges: any = {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
}
invalidDates: moment.Moment[] = [moment().add(2, 'days'), moment().add(3, 'days'), moment().add(5, 'days')];
isInvalidDate = (m: moment.Moment) => {
return this.invalidDates.some(d => d.isSame(m, 'day') )
}
constructor() {
this.alwaysShowCalendars = true;
}
<input type="text"
ngxDaterangepickerMd
[(ngModel)]="selected"
[showCustomRangeLabel]="true"
[alwaysShowCalendars]="true"
[ranges]="ranges"
[linkedCalendars]="true"
[isInvalidDate] = "isInvalidDate"
[showClearButton]="true"
placeholder="Select please.../>
https://fetrarij.github.io/ngx-daterangepicker-material/custom-ranges