I am trying to enable dates in flatpickr calender which is integrated with angular. So when I am trying to push enable date object to enable config option of flatpickr then I am getting Argument of type '{ from: string; to: string; }' is not assignable to parameter of type 'string | Date'.
Here is the code for config. of flatpickr:-
dateFormat: "d.m.Y",
minDate: "today",
maxDate: "",
onChange: function (selectedDates, dateStr) {
// console.log('selected date is ', selectedDates);
console.log('latest selected dates ', dateStr);
this.selectedDate = selectedDates;
this.dateSelected = selectedDates;
console.log('this.dateSelected ', this.dateSelected);
console.log('this.selectedDate ', this.selectedDates);
}
};```
In a function I am using that config object to enable dates:-
``` allAboutDateAndTime(){
if (this.experienceData.dateRangeList != null && this.experienceData.dateRangeList != undefined && this.experienceData.dateRangeList.length > 0) {
this.experienceData.dateRangeList.forEach((date: DateRange) => {
const from = date.startDate.toString();
const to = date.endDate.toString();
const enable = {
from: from,
to: to
};
this.exampleOptions.enable.push(enable); // GETTING ERROR HERE
});
}```
This is the error I am getting ```Argument of type '{ from: string; to: string; }' is not assignable to parameter of type 'string | Date'.
Type '{ from: string; to: string; }' is missing the following properties from type 'Date': toDateString, toTimeString, toLocaleDateString, toLocaleTimeString, and 38 more```
I am expecting it to enable the assigned dates as given in flatpickr [documentaion](https://flatpickr.js.org/examples/)
Aucun commentaire:
Enregistrer un commentaire