4

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.

mruanova
  • 6,351
  • 6
  • 37
  • 55
  • Did you find any reason for this error? – B.Y Jan 02 '18 at 09:59
  • 1
    I was trying to assign to a variable a function that wasn't returning a value, this function was the observable object, that is why there was no debug context, I posted here in the answer the correct was to use an observable. – mruanova Jan 02 '18 at 21:37

2 Answers2

1

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

Muhammed Moussa
  • 4,589
  • 33
  • 27
0

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

mruanova
  • 6,351
  • 6
  • 37
  • 55