Skip to content

Help with disableDayFn  #18

@rafla182

Description

@rafla182

I'm having to always recreate the "datepickerOptionsDate". When I change month it assigns to the first day of the month to recharge.

I wish it only changed in the function.

I tried this.datepickerOptionsDate.disableDayFn and it did not work.

Can anybody help me?

Thanks.


ngOnInit() {

    this.titleService.setTitle('Agendamento - Portal de Parceiros Peixe Urbano');

    moment.locale('pt-br');

    this.dateFilter = moment(Date());

    this.datepickerOptionsDate = {
      displayFormat: 'dddd, DD MMM YYYY',
      inputClasses: ['form-control', 'group-left'],
    };

    this.list();
    this.getAvailabilityCalendar(this.dateFilter);
  }

  getAvailabilityCalendar(dateMoment: Moment) {

    let firstDate = dateMoment.format('YYYY-MM-01');
    let lastDate = dateMoment.format('YYYY-MM-') + moment().daysInMonth();
    this.scheduleService.getAvailabilityCalendar(firstDate, lastDate)
      .subscribe(response => {
        this.daysUnavailable = response;

        this.datepickerOptionsDate = {
          showEmptyRow: false,
          displayFormat: 'dddd, DD MMM YYYY',
          showDayQuickOptions: false,
          inputClasses: ['form-control', 'group-left'],
          disableDayFn: (dayMomentInstance) => {
            let dateMoment = moment(dayMomentInstance).format('YYYY-MM-DD');
            return this.daysUnavailable.find(p => moment(p).format('YYYY-MM-DD') === dateMoment);
          }
        }
      },
      error => {
        this.errors = error;
      });
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions