fragaria / angular-daterangepicker

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

there is a bug in latest version #146

Closed wubin1989 closed 5 years ago

wubin1989 commented 8 years ago

after bower install command, I installed the latest version, but I got a error from angular.js

'cannot read the property of startdate of undefined'

I could not figure out the reason, so I copied the code from the project already deployed in our server, the error disappeared.

Hope you can test the code again, and fixed the problem.

djcam commented 8 years ago

I had the same issue. The source is the block 91-97:

          if (opts.singleDatePicker && objValue) {
            return f(objValue);
          } else if (objValue.startDate) {
            return [f(objValue.startDate), f(objValue.endDate)].join(opts.locale.separator);
          } else {
            return '';
          }

The the second condition needs to check to ensure that singleDatePicker has not been specified in the options. By replacing with the following the issue is resolved:

          if (opts.singleDatePicker && objValue) {
            return f(objValue);
          } else if (!opts.singleDatePicker && objValue.startDate) {
            return [f(objValue.startDate), f(objValue.endDate)].join(opts.locale.separator);
          } else {
            return '';
          }
ostlund commented 8 years ago

There is a pull request for this: #136