fragaria / angular-daterangepicker

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

Angular throwing digest error when passing moment obj to minDate or maxDate in options #238

Closed ghost closed 5 years ago

ghost commented 7 years ago

Hi! I am wracking my brain trying to solve this issue. Whenever I pass a moment obj (as per #100 ) into either minDate or maxDate of my options object, I get an Angular digest error: angular.js:9860 Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!

This doesn't occur if I pass in a string date, but then the max & min dates aren't correct in the calendars in the range picker. I have no trouble passing moment objects into the model.

Template: <button type='button' class='btn btn-md' ng-class='"btn-default"' date-range-picker ng-model='datePicker' options='datePickerOptions'><i class='fa fa-calendar fa-lg fa-fw'></i></button>"

Scope objects in controller: $scope.datePicker = { "startDate": moment().subtract(6, 'days'), "endDate": moment() }; $scope.datePickerOptions = { "autoApply": true, "minDate": moment('2015-11-01'), "maxDate": moment('2016-12-31'), locale: {format: 'MMMM D, YYYY'} };

I am stumped and could use help!

Edit: Forgot to mention I'm running the latest versions.

ghost commented 7 years ago

To make things weirder, if I use a JS Date obj, it seems to accept it without a problem.