¿Cómo puedo mostrar una serie de días en mat-calendar, como por ejemplo, tengo el siguiente arreglo:
Array: ['MO', 'TH', 'FR'] Y quiero que al iniciar el componente mat-calender , solo y solo los días que el arreglo esté habilitado (['MO', 'TH', 'FR'])
Actualmente, tengo algo como esto:
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 que carga hasta que haya leído dayAvaibality
<mat-calendar [dateFilter]="dateFilter" *ngIf="dayAvaibality"></mat-calendar>Lo que me muestra actualmente:
ingrese la descripción de la imagen aquí
¿Cómo mostrar solo el rango de días en mat-calendarwith momentJS? Por favor ayúdenme, estoy desesperada, he probado varias cosas, no encuentro un solo ejemplo, me ayuda. soy nueva programacion