Angular 基于休息结果禁用日期

Angular 基于休息结果禁用日期,angular,datepicker,mat-datepicker,Angular,Datepicker,Mat Datepicker,我使用的是角材料日历,即垫日历。我正试图基于动态值禁用日历中的某些日期 HTML 如果您有任何想法或方法以编程方式更改禁用的日期 感谢要在filterDates方法中引入上下文,您需要使用箭头函数,而不是像以前那样将其声明为常规方法,否则this关键字将引用matDateFilter类中的上下文,其中管道和apiResult不存在: filterDates=日期:日期:布尔=>{ 如果this.apireult!==未定义{ 设d=this.pipe.transformdate,‘yyyy-MM

我使用的是角材料日历,即垫日历。我正试图基于动态值禁用日历中的某些日期

HTML

如果您有任何想法或方法以编程方式更改禁用的日期
感谢

要在filterDates方法中引入上下文,您需要使用箭头函数,而不是像以前那样将其声明为常规方法,否则this关键字将引用matDateFilter类中的上下文,其中管道和apiResult不存在:

filterDates=日期:日期:布尔=>{ 如果this.apireult!==未定义{ 设d=this.pipe.transformdate,‘yyyy-MM-dd’; 返回this.apisresult.hasd; }否则{ 返回true; } }
    <mat-calendar [headerComponent]="exampleHeader" [dateFilter]="filterDates"></mat-calendar>
  public filterDates(date: Date): boolean {
    if (this.apiResult !== undefined) {
      let d = this.pipe.transform(date, 'yyyy-MM-dd');
      return this.apiResult.has(d);
    } else {
      return true;
    }
 }