I am working on progressive web app where I have user registration and login . But I am solution how can I enable the logout button in the side menu when user logs in or register .
I have read about the events but did not get much idea how to achieve that . For reference I am attaching my screen shot .
import {Events} from 'ionic/angular';
export class MyApp {
showButton : any=false; //will not show the log out button by default
constructor(public events : Events){
// Listening for the event when the user has logged in
this.events.subscribe('loggedin', ()=>{
this.showButton = true // will show the log out button now
}
}
}
Now, in the .ts file of the page where you want the menu to show the button (the page where a user has logged in), publish the event
page.ts
import {Events} from 'ionic-angular';
export class MyPage {
constructor(public events : Events){
}
ionViewDidLoad(){
this.events.publish('loggedin');
}
}