Chapter 8. Building a Tab-Based App

A very common type of application you might build is one that uses a tab-based navigation system. This design pattern works very well when you have a limited number (five or fewer) of groups (or tabs) of content. We are going to use this design pattern to create an app that will allow you to explore the various US national parks (in honor of them celebrating their centennial in 2016). Figure 8-1 shows what our final app will look like.

We are again going to use the Ionic CLI to scaffold our application. First, create a new directory that we will be building from. I named my directory IonicParks:

$ ionic start IonicParks --v2

Since we are going to be creating a tabs-based app, we did not need to pass in a template name, since the tab template is the default.

Next, change your working directory to the newly created IonicParks directory:

$ cd IonicParks
Figure 8-1. Ionic national parks app

Now let’s explore the template itself (Figure 8-2) before we get down to business:

$ ionic serve
Figure 8-2. Ionic tabs template

Not a lot here, but we can navigate between the three tabs (named Home, About, and Contact), and see the content change.

Taking a look inside the app.module.ts file, we see that instead of importing one page, we now are importing ...

Get Mobile App Development with Ionic 2, 1st Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.