Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?

Hi there,

Updating from ionic 4 beta 8 to ionic 4 beta 11 caused our log-out page to break when using NavigationController.navigateRoot("/login");

it breaks with the following error and js seems to just stop running.

Navigation triggered outside Angular zone, did you forget to call ‘ngZone.run()’?

When using NavigationController.naviateBack("/login") it works fine. Also this is not the only place in the systeem we use navigateRoot. For example on a succesfull login we also set tabs as the root which still works fine.

Any help would be appreciated,
Robin

1 Like

you solved that one? maybe with beta.12? do you call your logout from an action sheet or alert or something?

Hi @HinderiksR,
Maybe this post can help you: AlertController/Ionic 4 Beta 7 - Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?

I had a similar problem and I solved it with ionic 4 beta 12 and this.zone.run(async () => {});

I hope it helps you. :slightly_smiling_face:

2 Likes

Hi codiobert,

Manually calling zone.run is a long term fix ? It seems a bit like a work around, since our app does not run in production at all i don’t might waiting for an actual fix.

a long term workaround :wink:

maybe I’m wrong, but even if in the future zone.run would not be needed to solve that particular issue anymore, it won’t harm to still have it there or is it?

Not sure, I’m not really certain what it actually does or if it has much overhead in performance (if any at all)

never noticed overhead in performance with zone

Thanks for share :+1: