v4: ion-datetime not working, ngModel/ionChange/ngModelChange not working as well!
See original GitHub issueIonic version: (check one with “x”) (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1) [ ] 2.x [ ] 3.x [x] 4.x
I’m submitting a … (check one with “x”) [x] bug report [ ] feature request
Current behavior:
ion-datetime doesn’t work in v4, unable to bind via ngModel, ionChange and ngModelChange doesn’t trigger any events.
Expected behavior:
Steps to reproduce:
Related code:
<ion-item>
<ion-label position="stacked">Event Time</ion-label>
<ion-datetime displayFormat="h:mm A" [(ngModel)]="eventTime" (ngModelChange)="save()" (ionChange)="timeChanged($event)" pickerFormat="h mm A"></ion-datetime>
</ion-item>
<ion-button (click)="save()" expand="block" fill="outline">Save</ion-button>
export class HomePage implements DoCheck {
eventTime: any;
save() {
console.log(this.eventTime); //undefined
}
timeChanged(event: any) {
console.log(event); //undefined
}
ngDoCheck() {
console.log(this.eventTime);
}
}
Other information:
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
ionic (Ionic CLI) : 4.0.0-rc.9 (C:\Users\albertc\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.0.0-alpha.7
@angular-devkit/core : 0.7.0-rc.0
@angular-devkit/schematics : 0.7.0-rc.0
@angular/cli : 6.0.8
@ionic/ng-toolkit : 1.0.0-rc.9
@ionic/schematics-angular : 1.0.0-rc.9
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:17 (4 by maintainers)
Top Results From Across the Web
Setting Date in Ionic Datepicker - Only Days changed and not ...
Setting Date in Ionic Datepicker - Only Days changed and not the Month - Using (ngModelChange) ... I have two date input, Start...
Read more >Ion-datetime: ngModelChange - ionic-v3
Any ideas on how to properly handle the date change in ion-datetime ? I resolved it by changing (ngModelChange) to (ionChange) .
Read more >Date picker popup in Ionic 6 | Damir's Corner
Now I have another problem in that when user clicks the Month/Year selection ( top left) the month/year picker wheel correctly appears but...
Read more >Release notes and release history for Mobiscroll
What's New. Bugfix release. This version fixes several bugs and performance issues for the timeline, scheduler, event calendar, agenda and date picker. It...
Read more >Ionic 6 ion-datetime | Complete guide - YouTube
Hello Friends, Welcome Back to @CodingTechnyks. In this video, we are going to work with Ionic 6 ion - datetime using #ionic #angular...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

had to write in a simple converter using the
pickerOptionsand moment.js to get my date needed.YMMV: I only used a date picker selecting month, day and year. If you are selecting times as well, you’ll need to include that properly inside of moment with the returned dateModel
It’s inconvenient and not exactly clean, but it works…
I am unable to duplicate this issue at all using beta.12. This included testing the
ionChangeevent and usingformControlNameas such.If this problem persists for you, please open a new issue with a link to a repo containing a sample application that duplicates the issue.
Thank you for using Ionic!