在我的 angular 12 应用程序中,我为我的组件使用了一个 A B C D E F
g h * 2 1 5
g i i - - 3
h q i 4 - -
g h t - - 6
,然后我通过构造函数注入了一个 ChangeDetectionStrategy.OnPush
。我想测试我的方法并确保我检测到变化。它总是告诉我它没有被调用。
ChangeDetectorRef
我不知道如何检查是否被调用,因为 spies 似乎不能很好地与 ChangeDetectorRef 配合使用。我试过的是这样的:
searchLabsByTextField(): void {
this.roomService.search(this.searchText).subscribe({
next: x => {
...
this.cdr.detectChanges()
}
})
}