Rag*_*hav 2 ionic-framework ionic4
I am working in my Ionic 4 project and I have used the native date picker plugin. It is working fine but I am not able to set the min and max date in it for the Android.
This is my tab2.page.html:
<ion-input formControlName="startchallenge" placeholder="Select Date" (click)="datePickershow()" [readonly]=true></ion-input>
Run Code Online (Sandbox Code Playgroud)
This is my tab2.page.ts:
datePickershow(){
this.datePicker.show({
date: new Date(),
mode: 'date',
androidTheme: this.datePicker.ANDROID_THEMES.THEME_HOLO_DARK,
minDate: new Date().toISOString(),
maxDate: new Date(new Date().setDate(new Date().getDate() + 10)).toISOString(),
}).then(
date => console.log('Got date: ', date)},
err => {
console.log('Error occurred while getting date: ', err)}
);
}
Run Code Online (Sandbox Code Playgroud)
I have used min and max date in Android after that the user is able to select the back date from today because I have used the min date as a today date but the problem is that user is able to select the previous date in Android.
Any help is much appreciated.
尝试这个:
minDate: new Date().valueOf(),
maxDate: new Date(new Date().setDate(new Date().getDate() + 10)).valueOf(),
Run Code Online (Sandbox Code Playgroud)
这将解决您的问题。
| 归档时间: |
|
| 查看次数: |
1998 次 |
| 最近记录: |