2017-07-27 64 views
0

我使用datepicker控件作爲模態。通過這我可以得到默認格式的結果日期。我想以dd-mm-yy格式顯示和存儲它。 在這種情況下,我該如何實現?如何在DatePicker控件中將結果默認日期格式修改爲此(dd-month-year)格式?

//Modalview function 
 

 
createdpModelView(args) { 
 
     let that = this; 
 
     let currentDate = new Date(); 
 
     let options: ModalDialogOptions = { 
 
      context: currentDate.toDateString(), 
 
      fullscreen: false, 
 
      viewContainerRef: this.viewContainerRef 
 
     }; 
 
     this.modalService.showModal(Datepicmodal, options) 
 
      .then((dateresult: Date) => { 
 
       console.log("date result " + dateresult); 
 
      
 
------------------------------------------------------------------ 
 
//here i am facing issue// 
 
       if (args === "issue") { 
 
let datePicker = this.page.getViewById<DatePicker>("datePicker"); 
 
let selectedDate = new Date(datePicker.year, datePicker.month - 1, datePicker.day); 
 
this.issuedateng = selectedDate; 
 
console.log("selected date " + selectedDate); 
 
       } 
 
------------------------------------------------------------------ 
 

 
else if (args === "expiry") { 
 
        this.expirydateng = dateresult; 
 
        
 
       } 
 
      }); 
 
}

在此先感謝。

回答

0

這就是我的做法。

<Button #dobFdwomponentPersonalInfo id="dobFdwomponentPersonalInfo" [text]="fdwPersonalInfo?.dob | date: 'dd - MMM - yyyy'" (tap)="openSelectDateModalScreen('dob')"></Button> 

希望這有助於