我通过在 Zone JS 之外运行另一个更改检测进程成功地显式发出事件。
尽管更改检测正在运行,但出现错误:递归调用 ApplicationRef.tick 错误。
查看其 API https://github.com/angular/angular/blob/4.4.3/packages/core/src/application_ref.ts#L347-L417
tick() 方法卡在 Try-Catch block 中并且不会进入 Final,因此引发递归错误。 563-576行
这是我在 Application.tick() 中调用的方法
public listenTeamOverview(assetName: string) {
console.log('parent : ' + assetName);
console.log('assetClass= ' + this.assetClass);
this.assetClass = assetName;
this.application.tick();
// setTimeout(function(app) {
// app.tick();
// }, 2000, this.application);
}
只想从概念上了解如何摆脱tick()方法的递归过程?
提前致谢
最佳答案
对我来说另一个可行的解决方案:使用 ChangeDetectorRef 而不是 ApplicationRef
constructor(private ref:ChangeDetectorRef) { }
somethingChanged() {
this.ref.detectChanges();
}
关于javascript - 递归调用 Angular 错误 : ApplicationRef. 刻度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46444102/