Issue with back button after navigating to page using menu from app.ts


#1

Using ViewChild and Nav option in Ionic2 I have implemented side menus. When I move from home page to any other page using side menu and then try to come back by clicking on the back button of my mobile(Android).
Apps get’s closed. Can anyone pls help in this app. It’s quite urgent

I have below code in app.html

<ion-menu [content]=“content”>


Menu

{{p.title}}

<ion-nav [root]=“rootPage” #content swipeBackEnabled=“false”>


in App.component.ts

import { Component, ViewChild } from ‘@angular/core’;
import { Nav, Platform,AlertController,ToastController } from ‘ionic-angular’;

@Component({
templateUrl: ‘app.html’
})
export class MyApp {
@ViewChild(Nav) nav: Nav;

rootPage: any = HomePage;

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);
}

pages: Array<{title: string, component: any}>;
constructor(public platform: Platform) {
this.pages = [
{ title: ‘Home’, component: HomePage },
{ title: ‘About Us’, component: AboutUs },
{ title: ‘Feedback’, component: Feedback },
{ title: ‘Terms’, component: Terms }
];
}