How can I add a Logout Tab in my ionic 2 sidemenu? If you are logged in you are on the DashboardPage. Right now I have a menu item "Logout" which just bring me to the HomePage. Here is the pages array in the app.component.ts with all menu items:
this.pages = [
{title: 'Dashboard', component: DashboardPage},
...
{title: 'Logout', component: HomePage}
];
But now I need to add logic behind the logout and not only a page switch. Is it possible to call a function logout() when I click on the Logout Tab instead of only go to HomePage?
EDIT:
Here is the openPage function:
openPage(page) {
this.nav.setRoot(page.component);
}
openPage
:if (page.title === 'Logout') { // Do logout stuff here } else {this.nav.setRoot(page.component); }
– Michael Doye