Kha Lid
Kha Lid

Reputation: 115

add pages to sidemenu of side menu project template

I created a project using the sidemenu template.

ionic start projectName sidemenu --v2

after that i generated another page using: ionic g page pageName

what I want to do is to add this generated page to the side menu.

can you please help me, I'm newbie to ionic.

Thanks in advance

Upvotes: 1

Views: 2549

Answers (1)

Sampath
Sampath

Reputation: 65860

You have to add your new page to the pages array as shown below.

Git repo: Sample Side menu

app.component.ts

import { PageNamePage } from "../pages/page-name/page-name";

    export class MyApp {

        this.pages = [
          { title: 'Page One', component: Page1 },
          { title: 'Page Two', component: Page2 },
          { title: 'Page Three', component: PageNamePage }//your new page
        ];
    }

You have to add new page as shown below inside the app.module.ts.I have removed default code for clarity.

app.module.ts :

import { PageNamePage } from "../pages/page-name/page-name";//your new page

@NgModule({
  declarations: [
    PageNamePage,//new page
  ],
  entryComponents: [
    PageNamePage,//new page
  ],
 })
export class AppModule { }

Side Menu Now :

enter image description here

Upvotes: 5

Related Questions