Search code examples
angularangular-cliecmascript-5zonezonejs

Angular debug context error Cannot read property ngDebugContext


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.


Solution

  • 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