I am a bit unhappy and confused in the side menu without appearing in different situations.
My application stream and their requirements: initially there is a landing page with 3 tabs and no side menu. There are products on the first tab, and you can add them to your cart. Once you add them to the cart, you can click the shopping cart to check. At this point, if the user is not already logged in, a pop-up window appears with the facebook login function. at a successful value, the order summary page is displayed for items added to the basket. Since the user is now logged in, a side menu should appear.
However, what happens, a menu icon appears, but when you click nothing happens. There are no errors in the console.
I have confirmed that if I do not check the login status, then the menu is displayed just fine on the landing page.
Corresponding 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>