Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic 3 ion-datetime component and "ion-date-selected" event

I'm new to AngularJS and got a problem with Ionic - I got a simple form, where I need to display a notification (Ionic's alert) if user selects particular date using ion-datetime component. In specification we can find ion-cancel event but there is nothing like ion-date-selected.

Is there a way I could detect, that user selected a date? ionChange doesn't do a job either, because it's being fired multiple times. I know, I can subscribe to the model and check if has changed but maybe there is a better/simpler way?

like image 551
arti040 Avatar asked Jan 04 '23 15:01

arti040


1 Answers

you can use the following code in your page.html:

   <ion-item>
  <ion-label>Date</ion-label>
  <ion-datetime displayFormat="MM/DD/YYYY" [(ngModel)]="myDate" (ngModelChange)="dateChanged()"></ion-datetime>
</ion-item>

and in your page.ts:

myDate:any
dateChanged(){
if (myDate== testDate){
// your code here
}
}
like image 52
Melchia Avatar answered Jan 13 '23 10:01

Melchia