我收到ChangeDetectorRef的以下错误。当其他组件使用ChangeDetectorRef时,不确定为什么突然发生。有人知道如何解决吗?它链接到Kendo Grid选择。
TypeError:无法读取未定义的属性'detectChanges'
export class DocumentPropertyGridComponent implements OnInit, OnChanges {
public documentPropertyGridDataSelected: Array<DocumentPropertyGridData> = new Array<DocumentPropertyGridData>();
constructor(private cdr: ChangeDetectorRef) {
}
selectTest(e){
this.documentPropertyGridDataSelected = e.selectedRows;
this.cdr.detectChanges();
}
HTML:
<div>
Selected Count: {{documentPropertyGridDataSelected.length}}
<div>
可能是this
上下文(顺便说一句,该函数如何调用?)。通过将其转换为箭头功能可修复
selectTest = (e) => {
this.documentPropertyGridDataSelected = e.selectedRows;
this.cdr.detectChanges();
}