Reputation: 4478
I m using Ionic datetime component in my ionic app
<ion-datetime
displayFormat="YYYY/MM/DD"
pickerFormat="YYYY MMMM DD" [(ngModel)]="summaryDate"
(ionChange)="getDashboardItemsByDate()">
</ion-datetime>
and in .ts file
I set default date to current date like this
public summaryDate: any = new Date().toISOString();
This works perfectly fine, but however the problem I have is, it invokes ionChange
event at the beginning (as I have set default value for this component). I just want to trigger this event when user selects the date not at the beginning when I set its default value.
Any help?
Upvotes: 13
Views: 14060
Reputation: 622
This should work fine
(ionChange)="changed($event)"
notice ($event)
Upvotes: 2
Reputation: 728
Use (ngModelChange)
of angular instead of (ionChange)
It's a bug from ionic. https://github.com/ionic-team/ionic/issues/7806 Try updating ionic to the last version, maybe it's fixed. But the angular way will work just fine.
Upvotes: 27