Javascript 在角材质中禁用带有假日列表和工作日(周六和周日)的mat datepicker
我试图禁用基于假期列表的日期(从api获取),并且我还想禁用工作日,即周六和周日。我可以禁用假日日期列表,但无法禁用工作日。这是我使用过的代码 } 现在,我把禁用周末的条件放在哪里 请帮我做这个。Javascript 在角材质中禁用带有假日列表和工作日(周六和周日)的mat datepicker,javascript,angular,angular-material,Javascript,Angular,Angular Material,我试图禁用基于假期列表的日期(从api获取),并且我还想禁用工作日,即周六和周日。我可以禁用假日日期列表,但无法禁用工作日。这是我使用过的代码 } 现在,我把禁用周末的条件放在哪里 请帮我做这个。 提前感谢。您可以添加功能来检查这一天是否是周末 holidayDateFilter = (d: Date): boolean => { // check if date is weekend day if (date.getDay() === 0 || date.getDay() ==
提前感谢。您可以添加功能来检查这一天是否是周末
holidayDateFilter = (d: Date): boolean => {
// check if date is weekend day
if (date.getDay() === 0 || date.getDay() === 6) {
return true;
}
// check if date is holiday
let d = moment(d);
if (this.holidayList) {
return !this.holidayList.find(x => {
return moment(x).isSame(d, 'day');
});
}
};
现在,我在这里要做的就是。我有一个类似于“cxxxxc”的字符串,其中C表示周日和周六是所有人的假日。我有另一个数组假日列表['date1'、'date2'…等等]。此日期数组还可以包含星期六和星期日。如何实现禁用周末的功能,当“CXXXXXX”以字符串形式出现并且在holidayList中时,某些日期是星期六。我现在已经实现了此代码。if(weekday==0 | | weekday==6){if(this.Saturday&&this.Sunday){return weekday!==0&&weekday!==6;}else if(this.sunday){return weekday!==0;}else if(this.sunday){return weekday!==6;}else{return true;}if(this.holidayList){return this.holidayList.find((x)=>{let holidayDates=moment(x).Isame(momentDate,'day');如果(holidayDates){return moment(x).isSame(momentDate,'day');}}}有人能帮忙吗。
holidayDateFilter = (d: Date): boolean => {
// check if date is weekend day
if (date.getDay() === 0 || date.getDay() === 6) {
return true;
}
// check if date is holiday
let d = moment(d);
if (this.holidayList) {
return !this.holidayList.find(x => {
return moment(x).isSame(d, 'day');
});
}
};