我正在與angular2的mydatepicker一起工作,我使用datepicker爲我的網站在2日期範圍內進行請願。但是我需要做一些驗證,比如最初的日期不是在最後的日期之後,反之亦然,最後的日期不能在最初的日期之前。Angular2 mydatepicker disableSince選項不起作用
so reading the documentation,我發現在選項對象中我可以設置這些屬性,事情是,他們不工作,至少不是實時的,如果我從他們工作的開始修復他們,但這沒有用爲我的網站。
這是HTML模板:
<div class="col-md-5" style="float: right">
<my-date-picker name="mydate" placeholder="Fecha final" [(options)]="optionsFechaFinal" (dateChanged)="onDateChanged($event,1)" required></my-date-picker>
</div>
<div class="col-md-5" style="float: right">
<my-date-picker name="mydate2" placeholder="Fecha inicial" [(options)]="optionsFechaInicial" (dateChanged)="onDateChanged($event,0)" required></my-date-picker>
</div>
和角碼:
private optionsFechaInicial: IMyOptions = {
// other options...
dayLabels: { su: "Do", mo: "Lu", tu: "Ma", we: "Mi", th: "Ju", fr: "Vi", sa: "Sa" },
monthLabels: { 1: "Ene", 2: "Feb", 3: "Mar", 4: "Abr", 5: "May", 6: "Jun", 7: "Jul", 8: "Ago", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dic" },
todayBtnTxt: "Hoy",
firstDayOfWeek: "mo",
sunHighlight: true,
dateFormat: 'dd/mm/yyyy',
selectionTxtFontSize: '13px',
height: '30px'
};
private optionsFechaFinal: IMyOptions = {
// other options...
dayLabels: { su: "Do", mo: "Lu", tu: "Ma", we: "Mi", th: "Ju", fr: "Vi", sa: "Sa" },
monthLabels: { 1: "Ene", 2: "Feb", 3: "Mar", 4: "Abr", 5: "May", 6: "Jun", 7: "Jul", 8: "Ago", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dic" },
todayBtnTxt: "Hoy",
firstDayOfWeek: "mo",
sunHighlight: true,
dateFormat: 'dd/mm/yyyy',
selectionTxtFontSize: '13px',
height: '30px'
};
/*some code not relevant*/
onDateChanged(event: IMyDateModel, datepicker: number) {
//datepicker inicial
if (datepicker == 0) {
this.optionsFechaFinal.disableUntil = event.date;
this.initialDate = Date.parse(event.date.year + '-' + event.date.month + '-' + event.date.day)/1000;
console.log(this.optionsFechaFinal.disableUntil);
//datepicker final
} else if (datepicker == 1) {
this.optionsFechaInicial.disableSince = event.date;
this.finalDate = Date.parse(event.date.year + '-' + event.date.month + '-' + event.date.day)/1000;
}
}
我不知道我是怎麼錯過了,什麼是錯的代碼?