How can I show an array of days in mat-calendar, like for example I have the following arrangement:
Array: ['MO', 'TH', 'FR']
And I want that when starting the mat-calender component, only and only the days that the arrangement is enabled (['MO', 'TH', 'FR'])
Currently, I have something like this:
dayAvaibality!: any;
ngOnInit(){
this.dayAvaibality = this.getAvaibility();
}
getAvaibility(){
let workingDays: string[] = [];
//If the user selected a place show me the calendar you have for that place
if(this.selectedPlace && this.selectedPlace.schedules){
//So it loops through the array once for each element of the array
this.selectedPlace.schedules.forEach((schedule: { days: any[]; }, index: any) => {
// And return the iteration of the array traversal and store it in the new element
// obtained
// in workingDays
Object.keys(DaysOfWeek).forEach((key, index) => {
if (schedule.days.some((day: string) => day == key)) {
workingDays.some(alreadyAddedDay => alreadyAddedDay == key) ? null : workingDays.push(key)
}
})
})
console.log('Days working', workingDays);
return workingDays;
}
else{
return console.error('Ha ocurrido un error');
}
}
dateFilter = (date: Date) => {
return this.dayAvaibality?.includes(moment(date).format('dd'));
}
enum DaysOfWeek {
"MO" = 1,
"TU" = 2,
"WE" = 3,
"TH" = 4,
"FR" = 5,
"SA" = 6,
"SU" = 7,
}
html: //NgIF that loads until it has read dayAvaibality
<mat-calendar [dateFilter]="dateFilter" *ngIf="dayAvaibality"></mat-calendar>
What it currently shows me:
How to display only range of days in mat-calendarwith momentJS? Pleaseee Help Me, I am desperate, I have tried several things, I can not find a single example, it helps. I am new programming