I'm submitting a ... (check one with "x")
nb-datepicker with NbMomentDateModule not working
Current behavior:
I added nb-datepicker to the html page and also added NbMomentDateModule but when the page loads , I get an exception in the console.
Exception:
ERROR TypeError: date.format is not a function
at NbMomentDateService.format (moment-date.service.js?7128:54)
at NbDateAdapterService.format (datepicker-adapter.js?5298:32)
at NbDatepickerDirective.writeInput (datepicker.directive.js?0efc:349)
at NbDatepickerDirective.writeValue (datepicker.directive.js?0efc:207)
at setUpControl (forms.js?8087:1645)
at FormGroupDirective.addControl (forms.js?8087:4454)
Expected behavior:
The datepicker should be initialized with moment() and value should be set when a date is selected
Steps to reproduce:
Related code:
insert short code snippets here
npm, node, OS, Browser
<!--
Node, npm: `node --version` and `npm --version`
OS: Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra?)
Browser: Chrome/Safari/Firefox/etc?
-->
Angular, Nebular
<!--
Check your `package-lock.json` or locate a `package.json` in the `node_modules` folder.
-->
Hi @tcbuzor, sound like you're using moment module with native js Date. What type of date did you pass to the nb-datepicker?
ERROR TypeError: date.getFullYear is not a function
Im gettin this error when add format="MM/dd/yy" in nb-datepicker component
ERROR TypeError: date.getFullYear is not a function
Im gettin this error when add format="MM/dd/yy" in nb-datepicker component
Same Issue. When I set my form fields and click for the calendar to open. I get the same error in the console and all the dates on the calendar are gone.
Hi DanishFayaz, I am also facing the same issue, are you able to solve it?
I quit nebular, now i'm using another framework. Nebular is good but these
kind of issues were very important to my project.
El dom., 6 de ene. de 2019 a la(s) 11:31, Ganapathy Mano (
[email protected]) escribió:
Hi DanishFayaz, I am also facing the same issue, are you able to solve it?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/akveo/nebular/issues/926#issuecomment-451755013, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ATJZK2P6bdOz7tedhZwZ6n4r7GdZhQ9oks5vAiTxgaJpZM4XywfU
.
@ganapathymano it seems the issue is with format string. Moment specifies that you need to escape format string like this: e.g. [format]="'MM[/]DD[/]YYYY'". Escape dividers with []. For me it works.
I found if you're getting date.getFullYear is not a function this more than likely means you haven't initialized the Date value, for example, if I had a function which received the "dateCreated" value:
somefunction(obj) {
obj.dateCreated
}
and I tried to assign this using ngModel in html, like:
<input> [(ngModel)="obj.dateCreated" </input>
it'll return date.getFullYear is not a function, but if I first created a new variable in the component and then assigned the date value to this new object, and used that on ngModel, the error wouldn't show:
public dateCreated = new Date()
somefunction(obj) {
dateCreated = new Date(obj.dateCreated);
}
@Dalejan what kind of other frameworks you use ?
Most helpful comment
I quit nebular, now i'm using another framework. Nebular is good but these
kind of issues were very important to my project.
El dom., 6 de ene. de 2019 a la(s) 11:31, Ganapathy Mano (
[email protected]) escribió: