Holoule
Holoule

Reputation: 1

How to affect current month automatically to a picker ? IONIC 4

I'm working under Ionic 4.

I'm developping an app that allows a firm to visualize and keep up to date well being indicator of their services. In order to do so, managers are giving a forecast of how their service is doing. They have to do that once a month.

I want to set the current month by default in the picker, for better UI experience and economy of clicks, but i'm not able to find a solution.

For now, the picker only displays the current month, but the user still have to click and select it.

Any help is much appreciated

Upvotes: 0

Views: 446

Answers (1)

Chandrakant Devani
Chandrakant Devani

Reputation: 336

Try with below solution :

home.page.html

<ion-content>

  <ion-item>
    <ion-label>MMMM</ion-label>
    <ion-datetime displayFormat="MMMM" [value]="myDate"></ion-datetime>
  </ion-item>

</ion-content>

home.page.ts

export class HomePage {
  myDate: String = new Date().toISOString();
  constructor(private modalCtrl: ModalController, private alertCtrl: AlertController) {}

}

Result :

enter image description here

Upvotes: 1

Related Questions