How I can do to make a button open an ion-datetime?
I have see 1 solution but for me I doesn’t work, just give an error.
I have Ionic version: 6.20.8
#The solution
<button ion-button icon-right (click)="picker.open()">
<ion-datetime #picker pickerFormat="DD MMMM YYYY" [min]="datePickerMin" [(ngModel)]="datePicker" (ionChange)="changeDate()"></ion-datetime>
<ion-icon name="calendar"></ion-icon>
</button>
the error the solution give me:
#My HTML code
<ion-fab horizontal="end" vertical="center">
<ion-fab-button
ion-fab
color="primary"
(click)="picker.open()"
*ngIf="picker"
(ionChange)="changeDate()"
>
<ion-icon name="calendar-outline" id="calendar-button"></ion-icon>
</ion-fab-button>
</ion-fab>
<ion-datetime #picker pickerFormat="HH:mm"></ion-datetime>
#My Typescript code
import { Component, OnInit, ViewChild } from '@angular/core';
import { ItemReorderEventDetail, IonDatetime } from '@ionic/angular';
export class DatesPage implements OnInit {
@ViewChild("picker") picker: IonDatetime;
}