Sidemenu not working in ionic2


#1

Hi Guys,

Am developing the application using ionic2.

In this an login page, after that am opening the side menu. In this scenario its working (sidemenu) fine as expected.
But before redirecting the sidemenu (home page), once tap on the login button am opening the model popup (to accept the terms & condistions) , once the user accepted the t&c then am redirecting the home page (sidemenu). In this scenario am not able to the open the side menu items.
If am removing the model popup , its working perfectly, Could any one please help on this.

Thank you!!

Regards,
Sridhar Etikala


#2

Show us some code, your description is not enough to understand what exactly is happening.


#3

Hi Sujan,
Thanks for responding.
Please find the below code.
app.components.ts
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage:any = LandingPage;
pages: Array<{title: string, component: any, icon:string}>
constructor(public platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, public menu: MenuController, public storage: Storage) {
// set up our app
this.pages = [
{ title: ‘Home’, component: HomePage, icon: ‘ios-home-outline’},
{ title: ‘Reports’, component: ReportsPage, icon: ‘ios-albums-outline’},
{ title: ‘Generate MPin’, component: GenerateMpinPage, icon: ‘ios-lock-outline’},
{ title: ‘Change MPin’, component: ChangeMpinPage, icon: ‘ios-unlock-outline’},
{ title: ‘Help’, component: HelpPage, icon: ‘ios-help-circle-outline’}
];
statusBar.styleDefault();
splashScreen.hide();
}
}

After this i was redirected to the some other (Landing) page:

In this page, on button click event i redirected the another page using below code:
openPopover(myEvent) {
let myModal = this.modalCtrl.create(PolicyPage);
myModal.present();
}

Then now am in Policy Page.
Then it will show the popup, in the popup i have some two button like ‘Accept’ & ‘Reject’. When am tapping on the Accept button then am dismissing the popup and redirect to the home page, like below.
this.viewCtrl.dismiss();
this.navCtrl.setRoot(HomePage);

In this scenario , side menu is not working.
Suppose from the from the Landing page instead of opening the popup, if i redirect to the home page directly then side menu is working fine. From the Landing page to Home page am redirecting like below.
this.navCtrl.setRoot(HomePage);

Thank you !!!
Please let me know, if anything required.

Best Regards,
Sridhar


#4

Please edit your post and use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.


#5

Even I have faced the same issue.

I have fixed this by using Events.

If you try to navigate page from modal, You will face with above issue.(Side menu will not work). Instead of navigating from modal ts, Try to navigate from parent ts by using Events.

Eg :

Parent ts :

events.subscribe(‘modal:finished’, (page) => {

if(page == 'yourpage') {
  this.navCtrl.push(YourPage);
}

});

Modal ts :

this.events.publish(‘modal:finished’, ‘yourpage’);

You can send from modal where you need to redirect after modal dismiss. Based on this condition you can redirect wherever you want.

Hope it will help someone.