Reputation: 341
In Angular ng-bootstrap datepicker Site link here, in Range Selection part while getting the code from Typecript section there is one import "import {after, before, equals} from './tools';".
From where we can getting this after, before classes?
Where do we get the tools file mentioned or from where we can get the file?
Upvotes: 0
Views: 2025
Reputation: 51
import { NgbDate } from '@ng-bootstrap/ng-bootstrap/datepicker/ngb-date'
This works!!
Upvotes: 4
Reputation: 117370
The intention for the mentioned tools.ts
file is that utilities located in this file are to be provided by an application developer. For now those are not part of the ng-bootstrap library, but we are planning on releasing similar utilities in the feature.
To make things worse we had a bug in the demo page and it wasn't obvious from where the tools.ts
file is coming and what is its content. The bug is fixed now and you can see a working example at https://ng-bootstrap.github.io/#/components/datepicker/examples
For the reference, the tools.ts
file contained the following utilities (we've dropped this file in the latest demo version and just inlined utils as part of the demo):
const equals = (one: NgbDateStruct, two: NgbDateStruct) =>
one && two && two.year === one.year && two.month === one.month && two.day === one.day;
const before = (one: NgbDateStruct, two: NgbDateStruct) =>
!one || !two ? false : one.year === two.year ? one.month === two.month ? one.day === two.day
? false : one.day < two.day : one.month < two.month : one.year < two.year;
const after = (one: NgbDateStruct, two: NgbDateStruct) =>
!one || !two ? false : one.year === two.year ? one.month === two.month ? one.day === two.day
? false : one.day > two.day : one.month > two.month : one.year > two.year;
You can see it all in action in a plunker forked from the demo page: http://plnkr.co/edit/2I13mvvJBSpX9jyG4p5V?p=preview
Upvotes: 1
Reputation: 391
it appears that it is defined in the datapicker-range. however it is not exported from here.
It also appears to be here: https://github.com/ng-bootstrap/ng-bootstrap/blob/master/src/datepicker/ngb-date.ts
This one is exported as NgbDate, so you should be able to do:
import { NgbDate } from '@ng-bootstrap/datepicker/ngb-date';
...
NgbDate.after
you may need to mess with the path a little (but i dont see an index file that pulls it together.
Upvotes: 0