2

我正在尝试从 ng2-bootstrap 日期选择器中禁用某些日期。我尝试了不同的选项,但日期没有被禁用。我怎样才能解决这个问题?

export class AppComponent {
    public dt:Date = new Date();
    public minDate:Date = void 0;
    public events:Array<any>;
    public tomorrow:Date;
    public afterTomorrow:Date;
    public formats:Array<string> = ['DD-MM-YYYY', 'YYYY/MM/DD', 'DD.MM.YYYY', 'shortDate'];
    public format:string = this.formats[0];
    public dateOptions:any = {
        formatYear: 'YY',
        startingDay: 1
    };
    // This is the property as it is in the documentation
    public dateDisabled:Array<{date:Date, mode:string}>;

    private opened:boolean = false;

    public constructor() {
        (this.tomorrow = new Date()).setDate(this.tomorrow.getDate() + 1);
        (this.afterTomorrow = new Date()).setDate(this.tomorrow.getDate() + 2);
        this.minDate = new Date();
        this.events = [
            {date: this.tomorrow, status: 'full'},
            {date: this.afterTomorrow, status: 'partially'}
        ];
        // This is my array with disabled dates
        this.dateDisabled = [
            {date: moment('13-07-2016', 'DD-MM-YYYY').toDate(), mode: 'day'}
        ];
    }

// This is the way I use the datepicker in my view
<datepicker [(ngModel)]="dt" [dateDisabled]="dateDisabled"></datepicker>
4

0 回答 0