Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigating back to root - menu toggle button broken

I am using Ionic 2.

Page 1 (SearchPage) -> popover -> Page 2 (MapPage) -> Page 1 (SearchPage) (menuToggle not working)

I have a root page (SearchPage):

html

<ion-header>
  <ion-navbar>
    <button menuToggle>
      <ion-icon name="menu"></ion-icon>
    </button>
  </ion-navbar>
</ion-header>

ts

  presentPopover(event: Event): void {
    let popover: Popover = this.popoverController.create(SearchPopOverPage, {
      ev: event,
      employeeModel: this.employeeModel
    });
    popover.present();
  }

Popover

  presentFilterMap(event: Event) {
    this.viewCtrl.dismiss().then(() => {
      this.nav.push(MapPage, {
        ev: event,
        employeeModel: this.employeeModel,
        fromSearch: true
      })
    });
  }

But when I try return to the root page (with a parameter), it displays the menu toggle button (3 lines), but when I click it it does not work (i.e. does nothing, where it should display the side menu).

ts (MapPage) file which returns to root:

  this.nav.insert(0, SearchPage, {
    employeeModel: this.employeeModel
  });

If I try popToRoot(options), this works and the menu toggle button is working. However, it does not reload the page with the new parameter.

Any ideas how I should navigate back to the root page with a parameter please?

Thanks

UPDATE: I have tried the following, but it does not go back to the root:

  let options = {
    employeeModel: this.employeeModel
  };
  this.nav.popToRoot(options);

UPDATE: I have also tried changing the popovers call to the next page, but with little success. Now the back button on the MapPage works, but when I go to the root page, the menuToggle is still not responding to clicks.

  presentFilterMap(event: Event) {
    this.nav.push(MapPage, {
      employeeModel: this.employeeModel,
      fromSearch: true
    }).then(() => {
      this.viewCtrl.dismiss();
    });
  }

If I don't dismiss the popover,

    this.nav.push(MapPage, {
      employeeModel: this.employeeModel,
      fromSearch: true
    });

then when I use the back button on the MapPage back to root, the popover is still there, and the menuToggle works as expected. But if I rather navigate back to the root page (which I need to do) then the popover is not there and the menuToggle is not responsive.

This means the issue is to do with the popover.

like image 434
Richard Avatar asked Aug 18 '16 11:08

Richard


1 Answers

 import { App } from 'ionic-angular';

constuctor(public app: App) {};

pushSignupPage() {
    this.viewCtrl.dismiss().then(() => {
      this.app.getRootNav().push(SignupPage);
    });
  }

this work for me. good luck

like image 116
Hadi Jahangiri Avatar answered Sep 28 '22 22:09

Hadi Jahangiri