Side menu's function doesn't work

#1

i try to create menu logout that call page login, but it sound co.logout is not function

i create component menu, should i edit code in app or component ?

here is my code, please help me`
app.html and heander menu.html ( the code was sae, i try create at menu.html before but that’s not display so i create at app.html)


<ion-menu side="right" [content]="content">
        <ion-header>
          <ion-toolbar>
            <ion-title>
            Menu
            </ion-title>
          </ion-toolbar>
        </ion-header>

<ion-content>
            
  <ion-list>
    <ion-list-header>
      My Acount
    </ion-list-header>
    <ion-list-header>
      Settings
    </ion-list-header>
    <button menuClose ion-item icon-left detail-none no-line>
      Report
    </button> 
    
    
    <button ion-item icon-left detail-none
    (click)="logout()">Logout
    </button>
    
  </ion-list>

</ion-content>     

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

and for function i create at header-menu.ts

import { Component } from '@angular/core';
import { NavController, App, Nav } from 'ionic-angular';
import { MenuController } from 'ionic-angular';

/**
 * Generated class for the HeaderMenuComponent component.
 *
 * See https://angular.io/api/core/Component for more info on Angular
 * Components.
 */
@Component({
  selector: 'header-menu',
  templateUrl: 'header-menu.html'
})
export class HeaderMenuComponent {

    constructor(public navCtrl: NavController, 
      public app: App, 
      public menuCtrl: MenuController) {
  console.log('Hello HeaderMenuComponent Component')
  }
  logout(){
    // Remove API token 
    const root = this.app.getRootNav();
    root.popToRoot();
}

}

thanks

#2

Hello,

the error means that from html side the function logout() in ts side is not accessable, mostly a typo or wrong ‘’. But this looks good. Maybe clear browser cache and restart ionic serve will help.

Best regards, anna-liebt

#3

thank u ann,

i’ll try that suggestion