My page stuck when i press logout button

i have problem only with this page,

import { Component, ViewChild } from ‘@angular/core’;
import { Nav, Platform } from ‘ionic-angular’;
import { StatusBar } from ‘ionic-native’;
import { Storage } from ‘@ionic/storage’;

import { Page2 } from ‘…/pages/page2/page2’;
import {Admin} from “…/pages/admin/admin”;
import {Page1} from “…/pages/page1/page1”;

templateUrl: ‘app.html’,
export class MyApp {
@ViewChild(Nav) nav: Nav;

rootPage: any = Page1;
pages: Array<{title: string, component: any}>;
public local : Storage;

constructor(public platform: Platform,public storage:Storage) {
this.local = new Storage();
// used for an example of ngFor and navigation
this.pages = [
{ title: ‘Page one’, component: Page1 },
{ title: ‘Page Two’, component: Page2 },
{ title: ‘Admin’, component: Admin }


initializeApp() {
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.

openPage(page) {
// Reset the content nav to have just this page
// we wouldn’t want the back button to show in this scenario
console.log(“logout check”);


when i write these lines

this.local = new Storage();
or when i press on logout function, my page stuck and i have to restart chrome browser again. i don’t know what the reason for it. what i’m trying to do is to get the token variable from storage and when i press logout to remove it. i’m not sure if it is the best way…

Is your storage added in providers in app.module.ts?

yes, i added it in app.module.ts

you are probably having this problem too.

try the workaround i posted

where to put this code? i’m not sure i understand.

look on my code and tell me where

try using this if you are not using to set your root inside logout method.


in your template html,

<ion-nav id="nav" #content [root]="rootPage"></ion-nav>
<ion-nav id="nav" #content></ion-nav>

And moreover when I tried to do the same flow before somehow it was not falling into place, not because of ionic, but the sequence of screen flows. So my suggestion is to keep your features in pages and move login/logout/signup as modals or popups, so whenever your user is signed in you can show the page if not show the login modal, you can do this check before you load contents of each page.

1 Like

thanks man, it works fine with your reccomend!

I think you should stop linking your new post and issues.

It is a feature to discuss related issues or support.

1 Like

okay, my appologize, i edit my post