我在项目中使用ngx-mydatepicker,我需要使用disableDates
选项,它是ngx-mydatepicker
自定义接口IMyDate
的数组。我的日期是Date
的数组。
示例:请参阅app.component.ts
TS
//normally this comes from an API call. They need to get
//assigned to the disableDates below.
invalidJsDates: Date[] = [new Date("2018-05-09"), new Date("2018-05-29")];
myOptions: INgxMyDpOptions = {
dateFormat: 'mm/dd/yyyy',
//disableDates: this.invalidJsDates //need to convert this to array of IMyDate
};
HTML
<div class="input-group">
<input class="form-control" style="float:none" placeholder="Select a date" ngx-mydatepicker name="mydate"
[(ngModel)]="model" [options]="myOptions" #dp="ngx-mydatepicker"/>
<span class="input-group-btn">
<button type="button" class="btn btn-default" (click)="dp.clearDate()">
<i class="glyphicon glyphicon-remove"></i> Clear
</button>
<button type="button" class="btn btn-default" (click)="dp.toggleCalendar()">
<i class="glyphicon glyphicon-calendar"></i>Toggle
</button>
</span>
</div>