I am bit super annoyed and confused on the side menu not showing up in different situations.
My app flow and requirement are: initially, there is a landing page with 3 tabs and no side menu. On the first tab, there are products and you can add them to cart. once u add those to the cart you can click the shopping cart for checkout. At this point, if user is not already logged in then a model popup shows up with sign in with facebook option. on a successful signin the order summary page shows up for the items added to the cart. As user is now logged in so the side menu should appear.
However, what is happening in the menu icon shows up but on clicking, nothing happens. There is no error in the console etc.
I have validated that if I do not check for user login status then on the landing page the menu shows up just fine.
Relevant code:
app.html
<ion-menu [content]="content" type="overlay" style="opacity:0.95">
<ion-header>
<ion-toolbar>
<ion-title>
Menu
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content style="background-color: #F5F5F6">
<ion-grid no-padding>
<ion-row style="padding-top:20px">
<ion-col text-center>
<button ion-button round (click)="doLogout()">Sign Out</button>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
</ion-menu>
<ion-nav [root]="rootPage" #content></ion-nav>
app.component.ts
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage:any = TabsPage;
}
home.html (first tab)
ion-header>
<ion-navbar>
<button *ngIf="core.user.loggedIn == true" ion-button menuToggle icon-only style="display: block !important;">
<ion-icon name='menu'></ion-icon>
</button>
<ion-title>Cakes</ion-title>
<ion-buttons end>
<button *ngIf="getCartCount() > 0" ion-button (click)="openCart()"><ion-icon name="cart"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
home.ts
openCart(){
console.log('start of open cart:' + this.core.user.loggedIn)
if(this.core.user.loggedIn == false){
//user not logged in so first show login screen
console.log('take to login screen')
let modal = this.modalCtrl.create(LoginPage);
modal.present();
}
}
Login.ts
doLogin(){
if (this.platform.is('cordova')) {
return this.fb.login(['email', 'public_profile']).then(res => {
const facebookCredential = firebase.auth.FacebookAuthProvider.credential(res.authResponse.accessToken);
firebase.auth().signInWithCredential(facebookCredential);
this.navCtrl.setRoot(OrderSummaryPage);
})
}
}
OrderSummaryPage.html
<ion-header>
<ion-navbar>
<button ion-button menuToggle icon-only style="display: block !important;">
<ion-icon name='menu'></ion-icon>
</button>
<ion-title>Order Summary</ion-title>
</ion-navbar>
</ion-header>
Do this: In you app.html
Within the constructor of your app.component.ts
Declare pages above:
Now where ever you want to show the side menu icon add this in the constructor of the page
this.menuCtrl.enable(true, 'login');
Where ever you do not want to show the menu
For your issue you may try this