Search code examples
angularjsdatetimeionic-frameworkdatetimepicker

Can't get Ionic's datetime picker to work and showup even


check example on docs: https://ionicframework.com/docs/v2/api/components/datetime/DateTime/ and https://ionicframework.com/docs/v2/components/#datetime

I'm making mobile-app with ionic+angular+cordova in VS. And I want to use simple datetime picker they have on their docs, with year, month & day. As those native looking scrollable selectors.

I've tried this in my page:

<ion-item>
    <ion-label>Date:</ion-label>
    <ion-datetime displayFormat="YYYY-MM-DD" [(ngModel)]="myDate"></ion-datetime>
</ion-item>

and js:

$scope.myDate = new Date();
$scope.myDate.toISOString();

But nothing else shows up except ion-item and ion-label. How do I make the 'ion-datetime'-element work?


Solution

  • I was using wrong version of Angular and Ionic(1.3). I need to use atleast Ionic 2 and AngularJS 2 to make the datetimepicker work. Other choice is to add it through plugins..