You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During initialization, the field is empty which is what is required by the project. When you click the input field, the ranges dropdown is triggered. But, when you select the 'Today' range, it does not do anything or gave the input field some values.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I am currently using the daterangepicker in my AngularJS project and here is my code:
self.patientDateRangePicker = { model: { startDate: null, endDate: null }, options: { autoApply: true, autoUpdateInput: false, opens: self.appSrv.rightToLeft ? 'left' : 'right', pickerClasses: 'custom-display', //angular-daterangepicker extra buttonClasses: 'btn', applyButtonClasses: 'btn-primary', cancelButtonClasses: 'btn-danger', locale: { applyLabel: self.$filter('translate')('FORMS.APPLY'), cancelLabel: self.$filter('translate')('DOCUMENTS.MENU.CANCEL'), customRangeLabel: self.$filter('translate')('REPORTS.TREATMENTS.CUSTOM_RANGE'), separator: ' - ', format: 'DD/MM/yyyy', }, ranges: { // SOURCE: https://stackoverflow.com/a/19837961/7610023 [self.$filter('translate')('REPORTS.TREATMENTS.TODAY')] : [moment(), moment()], [self.$filter('translate')('REPORTS.TREATMENTS.YESTERDAY')]: [moment().subtract(1, 'days'), moment().subtract(1, 'days')], [self.$filter('translate')('REPORTS.TREATMENTS.LAST_7_DAYS')]: [moment().subtract(6, 'days'), moment()], [self.$filter('translate')('REPORTS.TREATMENTS.LAST_30_DAYS')]: [moment().subtract(29, 'days'), moment()], [self.$filter('translate')('REPORTS.TREATMENTS.LAST_MONTH')]: [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')], [self.$filter('translate')('REPORTS.TREATMENTS.THIS_MONTH')]: [moment().startOf('month'), moment().endOf('month')], [self.$filter('translate')('REPORTS.TREATMENTS.THIS_YEAR')]: [moment().startOf('year'), moment().endOf('year')] }, eventHandlers: { 'apply.daterangepicker': function(event, picker) { self.filters.creationStartDate = event.model.startDate.toDate(); self.filters.creationEndDate = event.model.endDate.toDate(); }, 'show.daterangepicker': function(event, picker) { self.showAdminBodyScroll = false; }, 'hide.daterangepicker': function(event, picker) { self.showAdminBodyScroll = true; self.filters.creationStartDate = event.model.startDate.toDate(); self.filters.creationEndDate = event.model.endDate.toDate(); } } } };
During initialization, the field is empty which is what is required by the project. When you click the input field, the ranges dropdown is triggered. But, when you select the 'Today' range, it does not do anything or gave the input field some values.
I did my research and found a discussion here: https://stackoverflow.com/a/56489427/7610023
As per the discussion stated above, can we remove this code below?
if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate))
I tried to do that and I don't see any issues.
Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions