Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "Expected to not be in Angular Zone, but it is!" error mean?

Tags:

angular

I started getting this error after upgrading from Angular 2 RC4 to RC5. It does not seem to be affecting the behaviour of the application but is being written to the console and could distract from other errors etc.

Can anyone provide some tips on how to troubleshoot it?

like image 851
Scott Munro Avatar asked Aug 26 '16 14:08

Scott Munro


1 Answers

This is an old question; however, as it featured prominently among Google's responses when I was searching for the solution to the same console message, I'll leave here what worked for me.

The code I'm working with was originally built with AngularJS, but development later switched to Angular2. When the app is loading, a bootstrap call is made with UpgradeAdapter, and apparently this was where the problem was occurring.

What I did was import NgZone from @angular/core and use the runOutsideAngular method to perform the bootstrap call. Once I did that, the error message went away. Example:

this.zone.runOutsideAngular(() => { performBootstrapCall(); });
like image 90
Rick Avatar answered Oct 17 '22 19:10

Rick