如何根据条件显示多个菜单



我是离子2

的初学者

下面是我的HTML代码,它使用它用于使用离子框架启用侧菜单

<ion-content>
<ion-list  *ngIf="!isUserLoggedIn()">
      <button menuClose ion-item  *ngFor="let p of loginPages"  (click)="openPage(p)">
        {{p.title}}
      </button>
    </ion-list>
    <ion-list  *ngIf="isUserLoggedIn()">
      <button menuClose ion-item  *ngFor="let p of logoutpages"  (click)="openPage(p)">
        {{p.title}}
      </button>
    </ion-list>
  </ion-content>

这是我的应用程序组件

  currentuser;
  @ViewChild(Nav) nav: Nav;
  auth:any;
  rootPage: any = LoginPage;
  loginPages:PageInterface[]=[
      { title: 'Login', component: LoginPage  }
  ];
  logoutpages :PageInterface[] = [
      { title: 'My Complaints', component: MycomplaintsPage },
      { title:'My Neighbours',component:NeighboursPage},
      { title:'Notifications',component:NotificationsPage},
      { title:'Directory',component:TabsPage},
      { title:'chat',component:ChatlistPage},
      { title:'Events',component:EventPage},      
      { title:'settings',component:SettingsPage},
      { title: 'LogOut',component:LoginPage,logsOut:true }
    ];
isUserLoggedIn(): boolean {
    let user = this.authservice.getcurrentuser();
 return user !== null;
  }

我已经根据isuserloggedin显示注销页面。我需要显示基于条件的Userrole的另一个菜单

请给我建议,谢谢问候

您可以为菜单提供ID,并根据条件启用或禁用菜单。https://github.com/driftyco/ionic/tree/master/demos/src/menu

menu.enable(true/false, #menu);

相关内容

  • 没有找到相关文章

最新更新