Ion-datetime: ngModelChange


#1

Hi,

I have a datetime like this :

<ion-datetime min={{today}} max="2018" (ngModelChange)="changeDate($event)"
	displayFormat="DD MMM. YY" [(ngModel)]="myDate">
</ion-datetime>

And i have this in my TS :

changeDate(_event) {
	console.log('Date : ' + JSON.stringify(new Date(this.myDate).toDateString()));
}

But each time i change the date in the datetime, the console log the date it used to be just before the last change.

For example, the first time i set the time to tomorrow, the console log the date of today(default date), and after, when i change the year to 2017, the console log the date of tomorrow.

Any ideas on how to properly handle the date change in ion-datetime ?


#2

I resolved it by changing (ngModelChange) to (ionChange).
I haven’t correctly read the docs :smile: