Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call markDisable method after received array with dates. #513

Open
jcmendes9898 opened this issue Mar 24, 2020 · 2 comments
Open

Call markDisable method after received array with dates. #513

jcmendes9898 opened this issue Mar 24, 2020 · 2 comments

Comments

@jcmendes9898
Copy link

Hi, I need to call the method for disabled dates after i received the dates. It s called when component load,

markDisabled = (date: Date) => { console.log("MARK_DISABLED") this.diaFeriadoArray.forEach(dia => { if (date.getTime() === new Date(dia.startTime.getFullYear(), dia.startTime.getMonth(), dia.startTime.getDate(), 12).getTime()) { console.log("entrou") return true } }) return date.getDay() === 0 || date.getDay() === 6 };

As at the time that it is called, diaFeriadoArray is empty so it does not entered in the forEach. Any tips?

@twinssbc
Copy link
Owner

@jcmendes9898 Unfortunately markDisabled can't be called after receiving the data. I think you can insert dummy events on these disabled dates, and use custom template to customize the dates that having dummy events, to display them as disabled look and feel.

@shanthan25
Copy link

you can reload the calendar after receiving the data using the below code.

<calendar *ngIf="!rerender" [markDisabled]="markDisabled"></calendar>

getDisabledDates() {
  markDisabled = (date: Date) => { console.log("MARK_DISABLED") this.diaFeriadoArray.forEach(dia => { if (date.getTime() === new Date(dia.startTime.getFullYear(), dia.startTime.getMonth(), dia.startTime.getDate(), 12).getTime()) { console.log("entrou") return true } }) return date.getDay() === 0 || date.getDay() === 6 };
  this.doRerender();
}

doRerender() {
  this.rerender = true;
  this.cdRef.detectChanges();
  this.rerender = false;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants