I am trying to use ionic native datepicker plugin. I am trying to use it with ion-input. upon click it should be able to select date and show the value in the input field. Unfortunately, when I use type ="date", it does pick and enter value from pop up calendar but at the same time it opens up two calendar. and If I change type to text or anything else, it pops up the calendar and doesn't allow me to select and enter value to field.
With time, I am not sure which type should I use?
Something like this In this you can see, when I click on input field, it opens light calendar behind the dark one
Also, is there anything else other than ion-input which I can use as a form field?
Below is my code:
<ion-item>
<ion-label floating>Date</ion-label>
<ion-input type="date" (input)="date = $event.target.value" [(ngModel)]="date" (click)="showCalendar()"></ion-datepicker>
</ion-item>
<ion-item>
<ion-label floating>Time</ion-label>
<ion-input (input)="time = $event.target.value" [(ngModel)]="time" (click)="showTime()" ion-time-picker></ion-datepicker>
</ion-item>
home.ts
showCalendar() {
this.datePicker.show({
date: new Date(),
mode: 'date',
titleText: 'set Date',
androidTheme: this.datePicker.ANDROID_THEMES.THEME_DEVICE_DEFAULT_LIGHT
}).then(
date => console.log('Got date: ', date),
err => console.log('Error occurred while getting date: ', err)
);
}
showTime() {
this.datePicker.show({
date: new Date(),
mode: 'time',
androidTheme: this.datePicker.ANDROID_THEMES.THEME_DEVICE_DEFAULT_LIGHT
}).then(
date => console.log('Got date: ', date),
err => console.log('Error occurred while getting date: ', err)
);
}