angular2-datetimepicker
angular2-datetimepicker copied to clipboard
DatePicker.html:60 ERROR TypeError: Cannot read property 'getMonth' of undefined(…)
please help.
I followed these steps
https://www.npmjs.com/package/angular2-datetimepicker
Is it within a form tag ? If so, you need to specify the name attribute.
Same issue with me as well. Yes it was under form and I do have specified name but still same error:
ERROR TypeError: Cannot read property 'getMonth' of undefined
at Object.eval [as updateDirectives] (DatePicker.html:60)
at Object.debugUpdateDirectives [as updateDirectives] (core.es5.js:13056)
at checkAndUpdateView (core.es5.js:12236)
at callViewAction (core.es5.js:12601)
at execEmbeddedViewsAction (core.es5.js:12559)
at checkAndUpdateView (core.es5.js:12237)
at callViewAction (core.es5.js:12601)
at execComponentViewsAction (core.es5.js:12533)
at checkAndUpdateView (core.es5.js:12242)
at callViewAction (core.es5.js:12601)
at execComponentViewsAction (core.es5.js:12533)
at checkAndUpdateView (core.es5.js:12242)
at callViewAction (core.es5.js:12601)
at execEmbeddedViewsAction (core.es5.js:12559)
at checkAndUpdateView (core.es5.js:12237)
If I move it outside form, it works fine - however, name property is still required.
We ran into this same issue. For some reason, when you use this component within a form, it tries to evaluate that bit of html before writeValue ever gets called. I have no idea why it does this, but we were able to fix the issue by setting this.date to a blank date in ngOnInit.
Here is the code luke added to make it work:
//add this to your component import { DatePicker } from 'angular2-datetimepicker';
//place this in your constructor DatePicker.prototype.ngOnInit = function() { this.settings = Object.assign(this.defaultSettings, this.settings); if (this.settings.defaultOpen) { this.popover = true; } this.date = new Date(); };
Luke is a wizard.
facing same issue, Please suggest right solution.
@brandon-sigao thanks very much, this worked for me.
Any news on fixing this properly?
thank you so much @brandon-sigao it works for me.
Thank you so much @brandon-sigao, this worked for me.
@brandon-sigao thank you so much.
@brandon-sigao thank you.
@brandon-sigao Thank you very much. This works.