1

My NgZone seems to no longer work.. I'm building an app using Ionic, Angular, and Firebase.

It produces an error:

Unhandled Promise rejection: Missing Command Error ; Zone: ; Task: Promise.then ; Value: Missing Command Error undefined

I've had it in my project for months, with no problems at all, and I use it in quite a few places, but all of a sudden it no longer works.

I import it normally:

import { Component, Input, NgZone, ViewChild, Injectable } from '@angular/core';

in the constructor

public zone: NgZone,

and then reference it like so:

this.zone = new NgZone({});

this.afAuth.auth.onAuthStateChanged((user) => {
  this.zone.run(() => {
    if (user) {
      this.rootPage = HomePage
    } else {
      this.rootPage = LoginPage
      console.log("Not logged in")
    }
    this.splashScreen.hide();
  });
});

But it doesn't work anymore...

My package.json calls the following dependency:

"zone.js": "0.8.18"

Any ideas what this might mean or what I should do? Thanks!

Simon
  • 2,498
  • 3
  • 34
  • 77

1 Answers1

1

please try to follow these steps:

1- import NgZone import { Component, NgZone, OnInit} from '@angular/core';

2- in constractor inside class constructor(private ngZone: NgZone) {}

3- remove this line this.zone = new NgZone({});

4- leave these lines of code as it

`this.afAuth.auth.onAuthStateChanged((user) => {
  this.zone.run(() => {
    if (user) {
      this.rootPage = HomePage
    } else {
      this.rootPage = LoginPage
      console.log("Not logged in")
    }
    this.splashScreen.hide();
  });
});`

try now....

Menna Ramadan
  • 465
  • 3
  • 12