1

I'm using the DateTime Ionic component and would like to set a minimum date for the date picker.

<ion-datetime displayFormat="DD MMM YYYY" min="getTodayDate()" monthNames="Janvier, Fevrier, Mars, Avril, Mai, Juin, Juillet, Aout, Septembre, Octobre, Novembre, Décembre" [(ngModel)]="date"></ion-datetime>

But the thing is that i don't know how to set it programatically. When I try with min="2017-12-01" everything works perfectly.

Here is the .ts:

@IonicPage()
@Component({
  selector: 'page-order-accept',
  templateUrl: 'order-accept.html',
})
export class OrderAcceptPage {
  public order: Order;
  public date: string;

  constructor(public navCtrl: NavController, public navParams: NavParams, public distribSP: DistributionStateProvider) {
    this.order = this.navParams.get("order");
    console.log(this.order.$id);        
  }

  ionViewDidLoad() {
    console.log(this.order.$description);
  }

  public validate(){
    this.navCtrl.pop();
    this.distribSP.flyersRetrievalState(this.order.$id,this.date).subscribe( data =>{

    });;
  }

  public back(){
    this.navCtrl.pop();
  }

  public getTodayDate(){
    let date: Date = new Date();
    return date.getFullYear()+"-"+date.getMonth()+date.getDate();
  }

Thanks for helping!!

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
OTmn
  • 185
  • 1
  • 2
  • 16

0 Answers0