0
我使用datepicker
從這裏https://github.com/kekeh/mydatepicker/blob/master/README.md,我需要禁用日期,直到今天,所以我需要得到當天的月份和年份,並通過它myDatePickerOptions我用新的日期()函數來獲取我的日期得到這樣的(星期四2017年4月6日15時55分09秒GMT + 0530(印度標準時間),所以不能使用它myDatepickerOptions
怎樣才能一天月份和年份?我曾嘗試下面的代碼。如何在datepicker中禁用今天直到今天?
import { Component, OnInit,ViewEncapsulation } from '@angular/core';
import { HeaderComponent } from '../header/header.component';
import {IMyOptions, IMyDateModel,IMyDate} from 'mydatepicker';
import { TimepickerConfig } from 'ng2-bootstrap/timepicker';
import { FormGroup,FormControl,Validators } from '@angular/forms';
@Component({
selector: 'app-createsession',
templateUrl: './createsession.component.html',
styleUrls: ['./createsession.component.css'],
encapsulation: ViewEncapsulation.None
})
export class CreatesessionComponent implements OnInit {
eventform : FormGroup ;
public mytime: Date = new Date();
private myDatePickerOptions: IMyOptions = {
// need use the current day,month and year
disableUntil: {year: 2016, month: 8, day: 10},
dateFormat: 'dd.mm.yyyy'
};
constructor() { }
ngOnInit() {
console.log(this.mytime);
});
}
onDateChanged(event: IMyDateModel) {
// event properties are: event.date, event.jsdate, event.formatted and event.epoc
}
onSubmit(){
console.log(this.eventform.value);
}
}
where應該我在ngOnInit()方法中設置currentyear,currentdate和month? –
你可以把它放在mytime下面。請找到我更新的答案。 – Vikash