Combination of a calendar datepicker and clock timepicker into one component for ionic 4.
npm install moots-datetime-pickernpm i luxon @angular/cdk @angular/flex-layout @angular/animations
npm i moots-datetime-picker
MootsPickerModule and dependencies in your AppModule:
ts
@NgModule({
...
imports: [
IonicModule.forRoot(MyApp),
FlexLayoutModule,
BrowserAnimationsModule,
MootsPickerModule
],
...
})
export class AppModule {}
`
Please find below an example as a quick start guide to get the picker running.
Modal
`ts
export class DemoModalBasicComponent {
date = new DateTime();
dateRange = {
from: this.date.valueOf(),
to: this.date.valueOf()
};
myCalendar;
constructor(public modalCtrl: ModalController) {}
async openCalendar() {
const options: PickerModalOptions = {
pickMode: PickMode.RANGE,
title: 'RANGE',
defaultDateRange: this.dateRange,
weekStart: 1,
step: 4,
locale: 'de'
};
this.myCalendar = await this.modalCtrl.create({
component: PickerModal,
componentProps: { options }
});
this.myCalendar.present();
const event: any = await this.myCalendar.onDidDismiss();
const { data: date, role } = event;
if (role === 'done') {
this.startDate = DateTime.fromMillis(event.data.from, { zone: 'Etc/UTC' });
this.endDate = DateTime.fromMillis(event.data.to, { zone: 'Etc/UTC' });
}
console.log(this.startDate);
console.log(this.endDate);
console.log('role', role);
}
}
`
Component
Coming soon!
Development Notes
To release a new version, commit all your changes and run:
- npm version patch to increment the version
- npm run packagr to build the library package
- go into the dist folder and run npm publish` to pubish it to npmjs