If you try to update the start date and end date from an external event it doesn't get updated. The reason is your render and attachment are called before the value is changed. That is the reason the component and the options are updated but input shows the same value.
Existing code:
DaterangePickerComponent.prototype.ngDoCheck = function () {
var optionsChanged = this._differ['options'].diff(this.options);
var settingsChanged = this._differ['settings'].diff(this.config.settings);
if (optionsChanged || settingsChanged) {
this.render();
this.attachEvents();
if (this.activeRange && this.datePicker) {
console.log("active");
console.log(this.activeRange);
this.datePicker.setStartDate(this.activeRange.start);
this.datePicker.setEndDate(this.activeRange.end);
}
}
};
A workaround for this is calling render and attachEvents after the start and end date is set, like this:
DaterangePickerComponent.prototype.ngDoCheck = function () {
var optionsChanged = this._differ['options'].diff(this.options);
var settingsChanged = this._differ['settings'].diff(this.config.settings);
if (optionsChanged || settingsChanged) {
if (this.activeRange && this.datePicker) {
console.log("active");
console.log(this.activeRange);
this.datePicker.setStartDate(this.activeRange.start);
this.datePicker.setEndDate(this.activeRange.end);
}
this.render(); // this is what makes it work
this.attachEvents();
}
};
If the existing code is intentional, I'd like to know what the correct workaround is. If my suggested workaround is acceptable, let me know, so I can make a pull request.
I have the same issue. I try to update start and end date by [options] but UI does not get updated.
@akshayinnopix Thank You for that work around! Works for me.
If you try to update the start date and end date from an external event it doesn't get updated. The reason is your render and attachment are called before the value is changed. That is the reason the component and the options are updated but input shows the same value.
Existing code:
A workaround for this is calling render and attachEvents after the start and end date is set, like this:
If the existing code is intentional, I'd like to know what the correct workaround is. If my suggested workaround is acceptable, let me know, so I can make a pull request.