Ng-bootstrap: ngb-datepicker - cannot read property 'day' of undefined

Created on 31 Oct 2018  Â·  3Comments  Â·  Source: ng-bootstrap/ng-bootstrap

I've been struggling with this for a couple of days now, had I had prior knowledge I would have gone for Angular material.

I am trying to implement a date range in an Angular 6 app as shown here:
https://stackblitz.com/angular/pdkqakgrpja?file=app%2Fdatepicker-range.ts
but the model binding {{ date.day }} is the problem.
Why is date not defined ?

datepicker invalid

Most helpful comment

THANKS TO A TYPO:
https://ng-bootstrap.github.io/#/components/datepicker/examples

THIS HAS COST ME TWO DAYS OF DEVELOPMENT TIME :(

The html IS NOT:

It is:

All 3 comments

THANKS TO A TYPO:
https://ng-bootstrap.github.io/#/components/datepicker/examples

THIS HAS COST ME TWO DAYS OF DEVELOPMENT TIME :(

The html IS NOT:

It is:

Hi @dotNetAthlete

Sorry to hear that. There ain't no typo from the documentation.

This code is valid

<ng-template #t let-date let-focused="focused">

It's just that it has been introduced in v3.3.0 and we do not maintain versioned documentation.
So whenever you look at https://ng-bootstrap.github.io/ it is the documentation for the latest stable version.

Thus, I presume you are using an older version trying to apply the datepicker documentation to your example.

Will see if we should add a disclaimer somehow in the demos/examples stating that this short $implicit template context for date has been introduced in 3.3.0

From the Api page it's clearly visible https://ng-bootstrap.github.io/#/components/datepicker/api#DayTemplateContext

image

Once again, I apologise for the time lost here. 😞

Thanks for the information.
I didn't understand implicit template properties !
Incidentally I updated to ng-bootstrap 4.0.0

On Fri, 2 Nov 2018 at 08:48, Benoit Charbonnier notifications@github.com
wrote:

Closed #2839 https://github.com/ng-bootstrap/ng-bootstrap/issues/2839.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ng-bootstrap/ng-bootstrap/issues/2839#event-1942422982,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKvNVS7hTD8ni9qrs6CHSDv5tdIfXgCYks5urAbMgaJpZM4YFUOP
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Palacios95 picture Palacios95  Â·  3Comments

beaverusiv picture beaverusiv  Â·  3Comments

BotanMan picture BotanMan  Â·  3Comments

kesemdavid picture kesemdavid  Â·  3Comments

mahmoudajawad picture mahmoudajawad  Â·  3Comments