材料表和工具提示上的 ExpressionChangedAfterItHasBeenCheckedError

时间:2021-04-25 20:43:12

标签: javascript angular angular-material

希望你能帮我解决这个问题。我正在尝试以编程方式隐藏/显示 matTooltip 并且我成功了,但向我抛出错误表达式已更改。当我检查是否必须显示工具提示时出现错误,并且我怀疑这是因为我检索数据的方式或者我遗漏了什么?

<table mat-table [dataSource]="vales$ | async">
     <!-- OTHER COLUMNS -->
     <ng-container matColumnDef="observacion">
    <th mat-header-cell *matHeaderCellDef>Observación</th>
      <td mat-cell *matCellDef="let vale">
           <label #obslbl class="ellipsis" matTooltip="{{vale.observacion}}"
              [matTooltipDisabled]="!checkOverflow(obslbl)">{{vale.observacion}} // Debugger show error on this line on checkOverflow
               </label>
      </td>
 </ng-container>

我的 ts 文件

ngAfterViewInit(): void {
  if (this.idAperturaPunto) {
    this.cargarVales();     
  }   
} 
...

cargarVales() {
  this.vales$ = 
this.cajaControllerNg.listTransaccionXidAperturaXVale(this.idAperturaPunto).pipe( tap(res => console.log(res))     );    
} 
...
checkOverflow(e: HTMLElement) {
return e.offsetWidth < e.scrollWidth;   
}

我尝试使用 ChangeDetectorRef 检查检测更改,但没有成功。提前致谢

0 个答案:

没有答案