fragaria / angular-daterangepicker

Angular.js wrapper for dangrossman/bootstrap-daterangepicker
MIT License
519 stars 372 forks source link

Add refreshing single date picker input and calendar on broadcasted event #155

Closed maicher closed 5 years ago

maicher commented 8 years ago

This applies only to single date picker.

Consider:

$scope.datePicker = {
  date: moment()
}

$scope.datePickerOptions = {
  singleDatePicker: true
}

Normally there is no possibility to change a date from controller, after the directive was initialized, by calling i.e.:

$scope.datePicker.date.add(1,'day')

Atfer modifing model value, calendar remine unrefreshed. In my last commit I've added a functionality, that allows to refresh calendar, by broadcasting an event, like:

$scope.datePicker.date.add(1,'day')
$scope.$broadcast('refresh-single-date-picker')

I needed that functionality, to create increment/decrement day buttons that are next to single date picker input. I've created a plnkr to show you what I mean.

I encourage you to merge those changes if you find that it is useful to other users. I'm open to prepare documentation, etc.