Side menu!

I’m new to Ionic and building a app using side menu template, and I already built a side-menu for admin. And I’m stuck at a problem.
How can I have two different menus one for user and another for admin in the same app? Please Help!!

hello, show me your side menu code, because answer of your question depends on how it looks like

this is my code:

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

import { HomePage } from ‘…/pages/home/home’;
import { ListPage } from ‘…/pages/list/list’;
import { CreateuserPage } from ‘…/pages/createuser/createuser’;
import { AddProjectPage } from ‘…/pages/add-project/add-project’;
import { AssignProjectPage} from ‘…/pages/assign-project/assign-project’;
import { AdminPage } from ‘…/pages/admin/admin’;
import { UsrprojPage } from ‘…/pages/usrproj/usrproj’;
import { UsrProfilePage } from ‘…/pages/usr-profile/usr-profile’;
import { UserhomePage } from ‘…/pages/userhome/userhome’;

@Component({
templateUrl: ‘app.html’
})
export class MyApp {
pagess: Array <{ title: string; component: any }>;
@ViewChild(Nav) nav: Nav;

rootPage: any = HomePage;

pages: Array<{title: string, component: any}>;

constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen) {
this.initializeApp();

// used for an example of ngFor and navigation
this.pages = [// admin menu starts-------------------------------
  { title: 'Home', component: AdminPage },

 // { title: 'List', component: ListPage },
 
  { title: 'Add User', component: CreateuserPage},
  { title: 'Add Project', component: AddProjectPage},
  { title: 'Assign Project', component: AssignProjectPage},
  { title: 'Logout', component: null},//admin menu ends-------------
 
];

}

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.
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}

openPage(page) {
if(page.component) {
this.nav.setRoot(page.component);
} else {
// Since the component is null, this is the logout option
// …

    // logout logic
    // ...

    // redirect to home
    this.nav.setRoot(HomePage);
}

}
}

you have your sidemenu options stored in array
just make something like

if(this.isAdmin == true){
   this.sideMenuArray = this.adminArray;
} else {
   this.sideMenuArray = this.normalArray;
}
1 Like

thanks I’ll try that! :slight_smile:

Can you please elaborate with an example as I’m stuck again.
I’m new to ionic and it’s important for me to learn.
thanks.