Ionic Tutorial
Ionic Tutorial
Ionic Tutorial
This Tutorial is for setting up a basic hybrid mobile application using the Ionic framework. The setup will
be shown for both Mac and PC computers using a virtual Android device.
Step 1: NodeJS
The first step requires us to download and install NodeJS. These steps differ on a Mac and PC. Here is
how we install NodeJS on both machine types:
Mac requirements:
Next, we need to download and install Homebrew. Open a terminal and type:
This will automatically install Homebrew. Homebrew will help us install NodeJS, which helps us
install Ionic’s dependencies.
PC requirements:
Go to NodeJS’s website ( https://nodejs.org/en/ ) and download the version of NodeJS that best
fits your machine (32 or 64 bit).
This will download an installer. Open the installer and use the default settings
Step 2: Ionic‐Cordova
Open up a terminal. Type npm install ‐g cordova ionic and hit enter.
This uses NodeJS’s package manager to install all the dependencies that Ionic needs to run. It also
installs all of Cordova’s dependencies. Cordova builds the application from your JavaScript source code
into IOS, Android, or Windows phone applications.
Create a new folder somewhere on your computer called IonicProjects. This directory is just to hold any
and all of your IonicProjects as you develop. Open a terminal in this new directory.
We now have 3 options. We can create a blank app from no template, create an app with 3 tabs at the
bottom for different pages, or an app with a side menu with 3 sample pages. For our example, we will
use the tabs template. At your terminal, type “ionic start walkthroughApp tabs”. When prompted, type
“y” so we can build for IOS and Android with Cordova:
It will take some time for this command to run. When it is done, it will have generated a new folder
called “walkthroughApp”, which you should change directory into:
Pick your favorite text editor or IDE to open the project folder “walkthroughApp”. For this tutorial, I will
be using Atom, which can be downloaded at https://atom.io/. Whichever text editor you use, open the
file src/pages/home/home.html:
Change the contents of the home page to simply say “Hello World!”
Next, I will show you how to run the app we created.
In order to run your app, we need a device. If you are using a Mac and have an Iphone, you can deploy it
on your actual phone using Xcode. If you have an Android device, you can deploy it on your actual
phone with Android Studios on both Mac and PC. For this tutorial, we will use a virtual Android device
on a PC. Details on the other deployment methods can be found here:
https://ionicframework.com/docs/intro/deploying/.
Finally! We are able to build and run the app. Open a terminal in your IonicProjects/walkThroughApp/
directory. At the terminal, type “ionic cordova emulate android ‐c ‐l ‐s”. This command builds your app
and deploys it to the virtual device that you just created. The options are as follows
‐c = console logs. Anything your print in your app will show up on the screen
‐l = enables live reload. Anytime you save changes to your code, it will reload your app with the changes
This command will take some time. After it executes, your emulator should start and our Hello World
homepage should be visible:
And that’s it! That’s all it takes to get a sample app up and running on a virtual device. To start coding
with Ionic, you need to start learning Angular2 and NodeJS.