Ionic not pushing to page neither rendering


#1

I’m calling this function in a service to go to another page. For example, after clicking in notification push message that I receive in app.component.ts, from a modal or whatever.

It works in the whole navigation of the app but sometimes push notificactions doesn’t redirect to the detail page.

import {Injectable} from "@angular/core";
import {NavController} from "ionic-angular";

@Injectable()

constructor() {
}

initRootNav(rootNav: NavController) {
    console.log(rootNav);
    this.rootNav = rootNav;
}

go(page: string, params?: any) {
    this.rootNav.push(page, params)
}

The page does ‘push’ because I can see all the info in console.log but view is not rendered. Uusually works the first time and never again.

I can see all logs but I am still in page1/modal1/whatever

ionViewDidLoad() {
    console.log('ionViewDidLoad');
}

ionViewWillEnter() {
    console.log('ionViewWillEnter');
    this.getData(); / does stuff
}

ionViewDidEnter() {
    console.log('ionViewDidEnter');
}

ionViewCanEnter() {
    console.log('ionViewCanEnter');
}

ionViewWillLeave() {
    console.log('ionViewWillLeave');
}

ionViewDidLeave() {
    console.log('ionViewDidLeave');
}

#2

It’s correct you can’t do that respectively you can’t use the navigation or other components like alert etc. in providers/service

You could only use such components in your pages or app.component.ts