ng2-bootstrap - 禁用日期

时间:2016-07-10 20:18:13

标签: angular testing ng2-bootstrap

我正在尝试从ng2-bootstrap datepicker中禁用某些日期。我尝试了不同的选项,但日期未被禁用。我该如何解决这个问题?

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>

0 个答案:

没有答案