I am using eonasdan datetimepicker and I can not manage to access the data functions from Angular controller.
The following code generates "TypeError: Cannot read property 'setValue' of undefined"
var d = new Date();
d.setHours(d.getHours() - 8);
m = moment(d);
$("#datetimepicker").data("DateTimePicker").setValue(m);
Since the onChange event is triggered in next code, the problem is not in the selector.
$("#datetimepicker").on("dp.change", function (e) {
console.log(e.date._d););
});
As I discovered the bootstrap-datetimepicker.js defines the DateTimePicker data, as well as it implements the setValue function.
if (!$this.data('DateTimePicker')) {
// create a private copy of the defaults object
options = $.extend(true, {}, $.fn.datetimepicker.defaults, options);
$this.data('DateTimePicker', dateTimePicker($this, options));
}
setValue = function (targetMoment)
What I do wrong ?