Ionic | App from Scratch – Two Sidemenus

Prepare your starter App

ionic start App sidemenu --type angular --no-git

Change into the newly create folder and start the Ionic App

cd App
ionic serve

You will see the default Ionic Sidemenu App

The entries of the sSidemenu are defined in app.components.ts:

export class AppComponent {
	public appPages = [
		{ title: 'Home', url: '/home', icon: 'home' },
		{ title: 'List', url: '/list', icon: 'list' }

The sidemenu itself and his apperance are defined in app.component.html:

  <ion-split-pane contentId="main-content">
    <ion-menu contentId="main-content" type="overlay">
          <ion-menu-toggle auto-hide="false" *ngFor="let p of appPages">
            <ion-item [routerDirection]="'root'" [routerLink]="[p.url]">
              <ion-icon slot="start" [name]="p.icon"></ion-icon>
    <ion-router-outlet id="main-content"></ion-router-outlet>

The Sidemenu entries and the Icon are added in line 13 and 14 to the sidemenu.

Define two sidemenus in app.html

<ion-menu [content]="contentLeft"> ....</ion-menu>
<ion-menu side="right" [content]="contentRight">....</ion-menu>

<ion-nav [root]="rootPage" #contentLeft #contentRight swipeBackEnabled="false"></ion-nav>

Add buttons to page

      <button ion-button start menuToggle>
         <ion-icon name="menu"></ion-icon>
      <ion-title>Demo of two Sidemenus</ion-title>
      <button ion-button end menuToggle="right">
<ion-content padding>
Github Repository

You can find the code here

Ionic | App from Scratch

Prepare Environment

Install Node.JS

nvm install $LATEST --latest-npm
node --version 
npm --version
nvm alias latest $LATEST
nvm alias default $LATEST

Install Ionic 4

npm -g install ionic@latest
ionic -version

Create an app from Template

ionic start --list
ionic start sidemenu sidemenu
ionic start super super

Introduction: First App

Prepare the base App

Create basic structure with tutorial template

ionic start app_from_scratch sidemenu --type angular
cd app_from_scratch

Some name changing

To keep the structure of the filenames the same, i like to change the name for the routing module (changing the dash to a dot)





Show base app

ionic serve -c

Add a page

Create a new page with the name “About”

ionic generate page About

Add import to app.components.ts

  public appPages = [
    { title: 'Home', url: '/home', icon: 'home' },
    { title: 'List', url: '/list', icon: 'list' },
    { title: 'About', url: '/about', icon: '' }

Add item to app-routing.module.ts

const routes: Routes = [
  { path: '', redirectTo: 'home', pathMatch: 'full' },
  { path: 'home', loadChildren: './home/home.module#HomePageModule' },
  { path: 'list', loadChildren: './list/list.module#ListPageModule' },
  { path: 'about', loadChildren: './about/about.module#AboutPageModule' }

Save the file now, and you will see the sidemenu entry:

Looks great, but… where is the sidemenu?

Ok, if you check the home page html code (, you will find a button for the side menu

    <ion-buttons slot="start">

Missing in


So, we had to add the desired code snippet

      <ion-buttons slot="start">

Add some Ionic Components

Look at the Ionic Preview App, or read the documentation, if you what to dive in immediately.

Or just copy some code from the documentation page and try by yourself:


We describe the steps to add additional components in detail in this blog.

Directory structure of an application

One possible way to build an app is:

  • create a base app from blank template
  • add desired pages, code and components

To find out the necessary steps to add an new page or component, look into the templates and compare a template with the blank template. the differences are the required steps to an a component.

For example, if you want to add tabs to your app, then compare the blank template with the tabs template:

ionic start starter_tabs  tabs --type angular --no-deps --no-git --no-link
ionic start starter_blank blank --type angular --no-deps --no-git --no-link

The diff command shows the changes between the to templates:

diff -r -w starter_tabs starter_blank
diff -r -w starter_blank/ionic.config.json starter_tabs/ionic.config.json
<   "name": "starter_blank",
>   "name": "starter_tabs",
diff -r -w starter_blank/package.json starter_tabs/package.json
<   "name": "starter_blank",
>   "name": "starter_tabs",
Only in starter_tabs/src/app: about
diff -r -w starter_blank/src/app/app-routing.module.ts starter_tabs/src/app/app-routing.module.ts
<   { path: '', redirectTo: 'home', pathMatch: 'full' },
<   { path: 'home', loadChildren: './home/home.module#HomePageModule' },
>   { path: '', loadChildren: './tabs/tabs.module#TabsPageModule' }
diff -r -w starter_blank/src/app/app.module.ts starter_tabs/src/app/app.module.ts
< import { RouterModule, RouteReuseStrategy, Routes } from '@angular/router';
> import { RouterModule, RouteReuseStrategy } from '@angular/router';
< import { AppComponent } from './app.component';
> import { AppComponent } from './app.component';
Only in starter_tabs/src/app: contact
diff -r -w starter_blank/src/app/home/home.module.ts starter_tabs/src/app/home/home.module.ts
> import { IonicModule } from '@ionic/angular';
> import { RouterModule } from '@angular/router';
< import { IonicModule } from '@ionic/angular';
< import { RouterModule } from '@angular/router';
>     IonicModule,
<     IonicModule,
<     RouterModule.forChild([
<       {
<         path: '',
<         component: HomePage
<       }
<     ])
>     RouterModule.forChild([{ path: '', component: HomePage }])
diff -r -w starter_blank/src/app/home/ starter_tabs/src/app/home/
<     <ion-title>
<       Ionic Blank
<     </ion-title>
>     <ion-title>Home</ion-title>
diff -r -w starter_blank/src/app/home/ starter_tabs/src/app/home/
<     })
<       .compileComponents();
>     }).compileComponents();
diff -r -w starter_blank/src/app/home/ starter_tabs/src/app/home/
<   styleUrls: [''],
>   styleUrls: ['']
< export class HomePage {
< }
> export class HomePage {}
Only in starter_tabs/src/app: tabs

Some differences comes from the different names (starter_blank vs. starter_tabs, HomePage vs. TabsPage). The important changes are those, which are new in the starter_tabs directory.