利用可能な日付と日付の有効期限に ng2-datepicker を使用しています。誰かが初期値を設定する方法を知っているかどうか疑問に思っていました。日付ピッカーのすべてが機能します。dateAvaliable
今日の日付になりたいだけです。 dateExpires
2099-12-31
<label>Date Avaliable:</label>
<div>
<ng2-datepicker name="dateAvaliable" [(ngModel)]="dateAvaliable" [ngModelOPtions]="{standalone: true}"> </ng2-datepicker>
</div>
<label>Date Expires:</label>
<div>
<ng2-datepicker name="dateExpires" [(ngModel)]="dateExpires" [ngModelOPtions]="{standalone: true}"> </ng2-datepicker>
</div>
成分
private today = new Date();
private dd: any = this.today.getDate();
private mm: any = this.today.getMonth() +1;
private year: any = this.today.getFullYear();
public sop: Sop;
public dateExpires: any;
public dateAvaliable: any;
ngOnInit() {
if (this.dd<10) {
this.dd ='0'+this.dd;
}
if(this.mm<10){
this.mm='0'+this.mm;
}
this.sop = {
description: "",
country: [this.countrys[4].value],
storeType: [this.storeTypes[4].value],
scoType: [this.scoTypes[6].value],
audience: [this.audiences[2].value],
sopType: [this.sopTypes[2].value],
dateAvaliable: this.year +'-'+this.mm+'-'+this.dd,
dateExpires: "2099-12-31"
}
}
これが私のインターフェースです
export interface Sop {
description: String;
country?: String[];
storeType?: String[];
scoType?: String[];
audience?: String[];
sopType?: String[];
dateAvaliable: any;
dateExpires: any;
}