It would be great if we could open the Datetime component just like an Alert component. This wouldn't require user interaction. This would make it much more flexible.
Which Ionic Version? or 2.x
currently exists a workaround to do this without user interaction?
Since it uses the Picker API underneath, you can call the Picker and create it that way, this isn't well documented: http://ionicframework.com/docs/v2/api/components/picker/Picker/
openPicker() {
let picker = Picker.create({
columns: [
{
columnWidth: "144px",
name: "month",
options: ["January", "February", "March"],
selectedIndex: 0
},
{
columnWidth: "144px",
name: "year",
options: ["90", "91", "92"],
selectedIndex: 0
},
],
buttons: [
{
text: "Cancel",
role: 'cancel',
handler: () => {
console.log("Clicked cancel")
}
},
{
text: "Done",
handler: (data: any) => {
console.log("Clicked done with", data);
}
}
]
});
this.nav.present(picker);
}
Hope that helps! See the Picker code for more info: https://github.com/driftyco/ionic/blob/2.0/src/components/picker/picker.ts
Agreed, this would be a nice improvement to the framework.
For this, the user's component could have a template variable, like <ion-datetime #myDatetime/>. Then @ViewChild('myDatetime') can be used to find the component. Next with that reference they can call present(). But I don't believe the present methods are exposed on something like ion-datetime or ion-select, so that's all we'll have to do (along with docs on how to do it).
any improvements on this issue?
by the way i found this article that shows a nice little workaround similar to @adamdbradley 's solution,
https://blog.jarmemori.es/tech/2016/09/14/display_ionic_datetime_picker_programmatically.html
+1
Hello everyone! Thanks for the feature request. I'm going to move this issue over to our internal list of feature requests for evaluation. We are continually prioritizing all requests that we receive with outstanding issues. We are extremely grateful for your feedback, but it may not always be our next priority. I'll copy the issue back to this repository when we have begun implementation. Thanks!
This issue was moved to driftyco/ionic-feature-requests#44
Any news on that since @jqw96 mentioned a feature request that was closed.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Most helpful comment
currently exists a workaround to do this without user interaction?