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?
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
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With