Angular debug context error Cannot read property ngDebugContext

6.2k Views Asked by At

I updated my version of angular from 2 to 4 and now I am getting this exception when executing a service:

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)

This error was injected . when I changed from hot to cold observables.

2

There are 2 best solutions below

0
On BEST ANSWER

i was have same issue for a while, and the reason was there is some functions return throw and calling was not handled with try catch.

this post maybe help Type-Safe Error Handling In TypeScript

0
On

I found the answer in this article. Turns out I wasn't returning the observable correctly in Angular.

https://blog.thoughtram.io/angular/2016/06/16/cold-vs-hot-observables.html#making-cold-observables-hot