我将Angular的版本从2到4更新到4,现在执行服务时我会得到此例外:
ERROR TypeError: Cannot read property 'ngDebugContext' of undefined
at getDebugContext (core.es5.js:994)
at isViewDebugError (core.es5.js:8451)
at callWithDebugContext (core.es5.js:13474)
at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.es5.js:13007)
at ViewRef_.detectChanges (core.es5.js:10174)
at core.es5.js:4812
at Array.forEach (<anonymous>)
at ApplicationRef_.tick (core.es5.js:4812)
at core.es5.js:4684
at ZoneDelegate.invoke (zone.js:392)
注入了此错误。当我从热可观察到。
我有一段时间存在相同的问题,原因是有一些函数返回 throw
,呼叫没有用 try catch
处理。
这篇文章可能会帮助打字稿中的类型安全错误
我在本文中找到了答案。原来,我没有在Angular中正确返回可观察的。
https://blog.thoughtram.io/angular/2016/06/16/cold-vs-hot-observables.html#making-colkaking-cold-cold-observables-hot