Closed ghoyle closed 5 years ago
Hi @ghoyle
Did you try to change value of options dynamically?
You have to make a copy of options and then change the value.
Here is an example: https://github.com/kekeh/angular-mydatepicker/wiki/options-attribute
Example on how to set disableSince option dynamically: https://github.com/kekeh/angular-mydatepicker/wiki/disable-since-tomorrow
Its the values of the calendar that i want to update. Changing the options shows the range on the initial load, but when using the buttons, the calendar obviously flicks between popup and inline but the range on the calendar doesnt update.
When you click the button you want to set visible range to calendar. When you click another button you want to set another visible range to calendar. Right?
Can you share the code what you did in the button click function?
See below:
public setRange = fromDate => {
this.dateRange = {
isRange: true,
singleDate: null,
dateRange: {
beginEpoc: fromDate.getTime() / 1000,
beginDate: {
day: fromDate.getDay(),
month: fromDate.getMonth(),
year: fromDate.getFullYear()
},
beginJsDate: fromDate,
endEpoc: this.todaysDate.getTime() / 1000,
endDate: {
day: this.todaysDate.getDay(),
month: this.todaysDate.getMonth(),
year: this.todaysDate.getFullYear()
},
endJsDate: this.todaysDate
}
};
};
It doesn't work now because there is a bug. I will fix it tomorrow and inform you. Thanks :-)
Hi @ghoyle
I fixed this issue. Please install version 0.1.4.
You can set value this way.
<input angular-mydatepicker class="datePicker" type="hidden"
[(ngModel)]="model" [options]="myDatePickerOptions"/>
public model: IMyDateModel = null;
// set range today + 3 days
onTodayPlus3(): void {
let today: Date = new Date();
let date: Date = new Date();
date.setDate(date.getDate() + 3);
this.model = {isRange: true, singleDate: null, dateRange: {
beginDate: {year: today.getFullYear(), month: today.getMonth() + 1, day: today.getDate()},
endDate: {year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate()}
}};
}
Sorry for the late reply, Ive been on holiday. Many thanks for the fix!
Hi, I've bound a date range to the input and want to show the calendar inline, but whenever updating the values via external buttons it wont show on the calendar. Ive tried showing not inline and closing and opening the popup shows the update. Is there any way to update inline?