I use the datetime component with the popover from the docs:
<!-- Datetime in popover with cover element -->
<ion-item button="true" id="open-date-input">
<ion-label>Date</ion-label>
<ion-text slot="end">{{ dateValue }}</ion-text>
<ion-popover trigger="open-date-input" show-backdrop="false">
<ng-template>
<ion-datetime
#popoverDatetime
presentation="date"
(ionChange)="dateValue = formatDate(popoverDatetime.value)"
></ion-datetime>
</ng-template>
</ion-popover>
</ion-item>
Is there a way to close the popover with the date selection? The standard behavior ist: Choose date and then click somewhere else to close the popover. I want to close it automatically.
[dismissOnSelect]="true" and popoverDatetime.confirm(true); closes immediately when the [(ngModel)] for the <ion-datetime> already has a value. So if there is no date it’s working fine. But then it’s not possible to change the date.
Is there also a solution?
The problem is, that I’ve to use [(ngModel)] in the ion-datetime with [(ngModel)]="startDate", otherwise it would not show the selected date in the calendar, when opening it to change the date.
But the [(ngModel)] seems to fire the [dismissOnSelect] when opening the popover so it closes immdediately. Without the [(ngModel)] the preselected date is not showing up and the user is confused what he has chosen before.
and, as I told you before, try to use the popover.dismiss() method instead of dismissOnSelect, doing this you will be sure that the popover won’t be close. You can put the popover.dismiss inside (ionChange)