Hey everyone, first post here so I’ll try to follow the format I have been seeing around the site.
The issue is that when I build and load the app onto my phone (iPhone 6+), the ion-buttons on the menu recognize the click event, but will only set the page as root if the page is already root. Push similarly doesn’t do anything. It seems like there have been a couple of people confused by this without any solution. Is there anyone who can weigh in?
Thanks,
Ray
app.html
<ion-menu [content]="content" side="right" type="overlay">
<ion-header>
<ion-toolbar [color]="'primary'">
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item (click)="openAccountPage()">
<ion-icon name="contact" item-start></ion-icon>
Account
</ion-item>
<button ion-item (click)="openContactPage()">
<ion-icon name="call" item-start></ion-icon>
Contact Information (Swap)
</button>
<ion-item menuClose detail-none>
<ion-icon name="exit" item-start></ion-icon>
Close Menu
</ion-item>
<button ion-item *ngFor="let p of pages" (click)="openPage(p)">
{{p.title}}
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav #content [root]="rootPage"></ion-nav>
app.component.ts
import { Component, ViewChild } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Platform } from 'ionic-angular';
import { MenuController } from 'ionic-angular';
import { AlertController } from 'ionic-angular'; //for dev testing;
import { TabsPage } from '../pages/tabs/tabs';
import { LoginPage } from '../pages/login/login';
import { ContactPage } from '../pages/contact/contact';
import { AccountPage } from '../pages/account/account';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild('content') nav: NavController;
rootPage:any;
title: any;
pages: Array<{title: string, component: any}>;
constructor(public platform: Platform, private alertCtrl: AlertController) {
this.pages = [
{ title: '', component: TabsPage },
{ title: 'Contact', component: ContactPage },
{ title: 'Account', component: AccountPage }
];
platform.ready().then(() => {
/* GLOBAL AUTH EVENTS */
this.events.subscribe('authentication:successful', () => {
this.events.publish('init:begin');
});
this.events.subscribe('authentication:failure', (e) => {
this.presentAlert("Auth Failed", e);
this.rootPage = LoginPage;
this.splashScreen.hide();
});
/* END GLOBAL AUTH EVENTS */
});
}
openPage(page) {
// Reset the content nav to have just this page
// we wouldn't want the back button to show in this scenario
this.nav.setRoot(page.component);
}
openContactPage(){
let alert = this.alertCtrl.create({
title: "ContactPage",
subTitle: "Should be displayed after this.",
buttons: ['Dismiss']
});
alert.present();
this.nav.push(ContactPage);
}
openAccountPage(){
let alert = this.alertCtrl.create({
title: "AccountPage",
subTitle: "Should be displayed after this.",
buttons: ['Dismiss']
});
alert.present();
this.nav.push(AccountPage);
}
}