Closed dennisbrandt closed 5 years ago
No one? I would be very grateful as this is really is starting to become a problem. SO question http://stackoverflow.com/questions/37221057/updating-date-on-startdate-selection-in-angular-daterangepicker
autoUpdateInput is forcefully being set to false? if I set it to true I get some output as invalid date in my model watch function, but at least on the single selection something is changing...
The issue is that the singleDatepicker is not meant to be run inline. Without it "closing" the date model will not update. This is not a bug, but a limitation of the current implementation. Triggering a click on the input can get it to work partially, but it's very hacky.
Yup, noticed as well that "autoUpdateInput is forcefully being set to false":
el.daterangepicker(angular.extend(opts, {
autoUpdateInput: false
}), function(start, end) {
return $scope.$apply(function() {
return $scope.model = opts.singleDatePicker ? start : {
startDate: start,
endDate: end
};
});
});
Any reason for that?
I had the same issue with startDate/endDate not being updated when the singleDatePicker:true option was set. In the end I discovered that for single date picker mode, you can just bind the model as a single date rather than an object containing startDate/endDate properties.
$scope.datepicker = {};
$scope.datepicker.opts = {
singleDatePicker: true
};
$scope.datepicker.date = moment();
<input date-range-picker options="datepicker.options" ng-model="datepicker.date" />
Hi there,
I am using the datepicker inline and have it set to single date. This works fine so far. I watch the date model to detect changes and then apply the new date to my factory. This works like a treat for a date range, However when I only select one date, the date model never changes on setting the start date, therefore my factory doesn't get updated.
app.controller("OnewayPickerCtrl",["$scope","$rootScope", "searchFactory", function($scope, $rootScope, searchFactory) { $rootScope.flyDates = { departureDate : "" }; $scope.date = {}; $scope.opts = { autoApply: true, minDate: moment(), //alwaysShowCalendars: true, parentEl: ".cal-block .form-group", autoUpdateInput: true, singleDatePicker: true }; $scope.$watch("date", function(newDate) { searchFactory.search.searchparams.journeys[0].departuredate = moment(newDate.endDate).format("YYYY-MM-DD"); }, false); } ]);
After some logging and disabling singleDate, I noticed that the date model only changes when the end date has been chosen. Is this a bug, or am I missing something? How can I watch for the start date updating in order to use singleDate instead of a range.
Appreciate any help