Reactive-Extensions / rx.angular.js

AngularJS Bindings for RxJS
Other
827 stars 89 forks source link

$$phase of null #52

Closed felixSchl closed 9 years ago

felixSchl commented 9 years ago

Every now and then I would get a cannot access $$phase of null exception using the scope scheduler.

Using the following seems to get around this, although I am not sure if this is the right way to do it:

(scheduler._scope.$$phase || (scheduler._scope.$root && scheduler._scope.$root.$$phase))
        ? fn()
        : scheduler._scope.$apply(fn);

Refer to scopescheduler.js

Also, I was wondering if it might be due to a $scope that was destroyed. Is there a way to have the scheduler dispose of the subscription when the $scope gets destroyed?

felixSchl commented 9 years ago

This is resolved by #53

PhiLhoSoft commented 8 years ago

For the record, I got this error as well, because we forgot a dispose of a subscribe in one controller. So the subscription was still there, but the controller supposed to handle it was destroyed, so was its scope.