Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Learning Ionic
Learning Ionic

Learning Ionic: Discover a simpler approach to modern mobile application development with Ionic framework and learn how to create elegant hybrid apps with HTML5 and AngularJS

eBook
$9.99 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Learning Ionic

Chapter 2. Welcome to Ionic

In the previous chapter, we saw a couple of key AngularJS features, namely the directives and services. In this chapter, we will understand the big picture of mobile hybrid apps, set up the required software to develop Ionic apps, and finally scaffold a few apps.

The topics covered in this chapter are as follows:

  • Mobile Hybrid Architecture
  • What is Apache Cordova?
  • What is Ionic?
  • Setting up the tools needed to develop and run Ionic apps
  • Working with Ionic templates
  • The Yeoman Ionic Generator

Mobile Hybrid Architecture

Before we start working with Ionic, we need to understand the bigger picture of the Mobile Hybrid platform.

The concept is pretty simple. Almost every mobile operating system (also called Platform when working with Cordova) has an API to develop apps. This API consists of a component named Web View. A Web View is typically a browser that runs inside the scope of a mobile application. This browser runs the HTML, CSS, and JS codes. This means that you can build a web page using the preceding technologies and then execute it inside your app.

You can use the same knowledge of web development to build native-hybrid mobile apps (here, native refers to installing the platform-specific format file on the device after it has been packaged along with the assets), for instance:

  • Android uses Android Application Package (.apk)
  • iOS uses iPhone Application Archive (.ipa)
  • Windows Phone uses Application Package (.xap)

The package/installer consists of a piece of native code that initializes...

What is Apache Cordova?

In simple terms, Cordova is the piece of software that stitches the web application and the native application together. The Apache Cordova website states that:

"Apache Cordova is a platform for building native mobile applications using HTML, CSS and JavaScript."

Apache Cordova does not just stitch the web app with the native app, but it also provides a set of APIs written in JavaScript to interact with the native features of the device. Yes, you can use JavaScript to access your camera, take a picture, and send it in an e-mail. Sounds exciting, right?

To get a better understanding of what is happening, let's take a look at the following image:

What is Apache Cordova?

As you can see, we have a web view where the HTML/CSS/JS code gets executed. This code can be a simple standalone piece of user interface; at best you are making an AJAX request to get some data from a remote server. Or, this code can do much more, like talking to the Bluetooth of the device and getting the list...

What is Ionic?

Ionic is a beautiful, open source, front-end SDK for developing hybrid mobile apps with HTML5. Ionic provides mobile-optimized HTML, CSS, and JS components, as well as gestures and tools for building highly interactive apps.

Ionic is performance efficient with its minimal DOM manipulation and hardware-accelerated transitions as compared to other frameworks in this league. Ionic uses AngularJS as its JavaScript framework.

With the power of AngularJS inside a framework like Ionic, the possibilities are unlimited (you can use any AngularJS component inside Ionic as long as it makes sense in a mobile app). Ionic has a very good integration with Cordova's device API. This means that you can access device APIs using a library like ngCordova and integrate it with the beautiful user interface components of Ionic.

Ionic has its own Command Line Interface (CLI) to scaffold, develop, and deploy Ionic apps. Before we start working with the Ionic CLI, we need to set up a few pieces...

Software setup

Now we are going to set up all the required software needed to develop and run an Ionic app smoothly.

Install Node.js

Since Ionic uses Node.js for its CLI as well as for the build tasks, we will first install the same as follows:

  1. Navigate to https://nodejs.org/.
  2. Click on the Install button on the homepage and an installer for your OS will automatically be downloaded. Or you can navigate to https://nodejs.org/download/ and download a specific copy.
  3. Install Node.js by executing the downloaded installer.

To verify that Node.js has been successfully installed, open a new Terminal (*nix systems) or Prompt (Windows systems) and run the following command:

 node -v

Now you should see the version of Node.js. Now execute the following command:

 npm -v

You should see the npm version:

Install Node.js

npm is a Node Package Manager that we will be using to download various dependencies for our Ionic Project.

Note

You need Node.js only during the development. The version specified in the preceding image is only for...

The platform guide

By the end of this book, we will be building apps that are ready to be deployed on to the device. Since Cordova takes HTML, CSS, and JS code as input and generates a platform-specific installer, you need to have the build environments available on your machine.

Note

Android users can follow the instructions on the Android Platform Guide at http://cordova.apache.org/docs/en/edge/guide_platforms_android_index.md.html#Android%20Platform%20Guide to set up SDK on your local machine.

iOS users can follow the instructions from the iOS Platform Guide at http://cordova.apache.org/docs/en/edge/guide_platforms_ios_index.md.html#iOS%20Platform%20Guide to set up SDK on your local machine.

You would need an OSX environment to develop iOS apps.

As of today, Ionic supports only Android 4.0+ (although, it works on 2.3 as well) and iOS 6+ mobile platforms. But Cordova supports a few more.

Note

You can check out the other supported platforms here: http://cordova.apache.org/docs/en/edge/guide_platforms_index...

Mobile Hybrid Architecture


Before we start working with Ionic, we need to understand the bigger picture of the Mobile Hybrid platform.

The concept is pretty simple. Almost every mobile operating system (also called Platform when working with Cordova) has an API to develop apps. This API consists of a component named Web View. A Web View is typically a browser that runs inside the scope of a mobile application. This browser runs the HTML, CSS, and JS codes. This means that you can build a web page using the preceding technologies and then execute it inside your app.

You can use the same knowledge of web development to build native-hybrid mobile apps (here, native refers to installing the platform-specific format file on the device after it has been packaged along with the assets), for instance:

  • Android uses Android Application Package (.apk)

  • iOS uses iPhone Application Archive (.ipa)

  • Windows Phone uses Application Package (.xap)

The package/installer consists of a piece of native code that initializes...

What is Apache Cordova?


In simple terms, Cordova is the piece of software that stitches the web application and the native application together. The Apache Cordova website states that:

"Apache Cordova is a platform for building native mobile applications using HTML, CSS and JavaScript."

Apache Cordova does not just stitch the web app with the native app, but it also provides a set of APIs written in JavaScript to interact with the native features of the device. Yes, you can use JavaScript to access your camera, take a picture, and send it in an e-mail. Sounds exciting, right?

To get a better understanding of what is happening, let's take a look at the following image:

As you can see, we have a web view where the HTML/CSS/JS code gets executed. This code can be a simple standalone piece of user interface; at best you are making an AJAX request to get some data from a remote server. Or, this code can do much more, like talking to the Bluetooth of the device and getting the list of devices in...

What is Ionic?


Ionic is a beautiful, open source, front-end SDK for developing hybrid mobile apps with HTML5. Ionic provides mobile-optimized HTML, CSS, and JS components, as well as gestures and tools for building highly interactive apps.

Ionic is performance efficient with its minimal DOM manipulation and hardware-accelerated transitions as compared to other frameworks in this league. Ionic uses AngularJS as its JavaScript framework.

With the power of AngularJS inside a framework like Ionic, the possibilities are unlimited (you can use any AngularJS component inside Ionic as long as it makes sense in a mobile app). Ionic has a very good integration with Cordova's device API. This means that you can access device APIs using a library like ngCordova and integrate it with the beautiful user interface components of Ionic.

Ionic has its own Command Line Interface (CLI) to scaffold, develop, and deploy Ionic apps. Before we start working with the Ionic CLI, we need to set up a few pieces of software...

Software setup


Now we are going to set up all the required software needed to develop and run an Ionic app smoothly.

Install Node.js

Since Ionic uses Node.js for its CLI as well as for the build tasks, we will first install the same as follows:

  1. Navigate to https://nodejs.org/.

  2. Click on the Install button on the homepage and an installer for your OS will automatically be downloaded. Or you can navigate to https://nodejs.org/download/ and download a specific copy.

  3. Install Node.js by executing the downloaded installer.

To verify that Node.js has been successfully installed, open a new Terminal (*nix systems) or Prompt (Windows systems) and run the following command:

 node -v

Now you should see the version of Node.js. Now execute the following command:

 npm -v

You should see the npm version:

npm is a Node Package Manager that we will be using to download various dependencies for our Ionic Project.

Note

You need Node.js only during the development. The version specified in the preceding image is only...

The platform guide


By the end of this book, we will be building apps that are ready to be deployed on to the device. Since Cordova takes HTML, CSS, and JS code as input and generates a platform-specific installer, you need to have the build environments available on your machine.

Note

Android users can follow the instructions on the Android Platform Guide at http://cordova.apache.org/docs/en/edge/guide_platforms_android_index.md.html#Android%20Platform%20Guide to set up SDK on your local machine.

iOS users can follow the instructions from the iOS Platform Guide at http://cordova.apache.org/docs/en/edge/guide_platforms_ios_index.md.html#iOS%20Platform%20Guide to set up SDK on your local machine.

You would need an OSX environment to develop iOS apps.

As of today, Ionic supports only Android 4.0+ (although, it works on 2.3 as well) and iOS 6+ mobile platforms. But Cordova supports a few more.

Note

You can check out the other supported platforms here: http://cordova.apache.org/docs/en/edge/guide_platforms_index...

Hello Ionic


Now that we are done with the software setup, we will scaffold a few Ionic apps.

Ionic has three main/go-to templates using which we can quickly start developing apps:

  • Blank: This is a blank Ionic project with one page

  • Tabs: This is a sample app that is built using Ionic tabs

  • Side menu: This is a sample app that is built to consume side menu driven navigation

To understand the basics of scaffolding, we will start with the blank template.

To keep our learning process clean, we will create a folder structure to work with Ionic projects. Create a folder named ionicApps, and then create a folder inside it called chapter2.

Next, open a new terminal/prompt and change the directory (cd) to the ionicApps folder and from there to chapter2 folder. Now run the following command:

ionic start -a "Example 1" -i app.example.one example1 blank

In the preceding command:

  • -a "Example 1": This is the human-readable name of the app

  • –i app.example.one: This is the app ID/reverse domain name

  • example1: This...

The browser developer tools setup


Before we proceed further, I would recommend setting up the developer tools in your browser in the following format.

Google Chrome

Once the Ionic app is launched, open the developer tools by pressing Cmd + Opt + I on Mac and Ctrl + Shift + I on Windows/Linux. Then click on the last but one icon in the top row, next to the close button as seen in the following screenshot:

This will dock developer tools to the side of the current page. Drag the demarcation line between the browser and the developer tools till you see the view becoming similar to a mobile.

If you click on the Elements tab in the developer tools, you can easily inspect the page and see the output in one go, as shown in the following screenshot:

This view is very helpful for fixing errors and debugging issues.

Mozilla Firefox

If you are a Mozilla Firefox fan, you can achieve the same result as above as well. Once the Ionic app is launched, open developer tools (not Firebug, Firefox's native development...

Left arrow icon Right arrow icon

Description

This book is intended for those who want to learn how to build hybrid mobile applications using Ionic. It is also ideal for people who want to explore theming for Ionic apps. Prior knowledge of AngularJS is essential to complete this book successfully.

What you will learn

  • Learn how a hybrid mobile application works Familiarize yourself with Cordova and see how it fits into hybrid mobile application development Seamlessly work with Ionic CSS components and Ionic-Angular JavaScript components such as directives and services Learn how to theme Ionic apps as well as customize components using Ionic SCSS support Develop an app that builds a client for a secure REST API using Ionic and AngularJS Develop a real-time chat app using Firebase that consumes ngCordova Learn how to generate a device-specific installer for an Ionic app using Ionic CLI as well as Ionic cloud services

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 24, 2015
Length: 388 pages
Edition : 1st
Language : English
ISBN-13 : 9781785281112
Vendor :
Drifty
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jul 24, 2015
Length: 388 pages
Edition : 1st
Language : English
ISBN-13 : 9781785281112
Vendor :
Drifty
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $29.97 $105.97 $76.00 saved
Getting Started with Ionic
$32.99
Learning Ionic
$48.99
Ionic Cookbook
$48.99
Total $29.97$105.97 $76.00 saved Stars icon
Banner background image

Table of Contents

11 Chapters
1. Ionic – Powered by AngularJS Chevron down icon Chevron up icon
2. Welcome to Ionic Chevron down icon Chevron up icon
3. Ionic CSS Components and Navigation Chevron down icon Chevron up icon
4. Ionic and SCSS Chevron down icon Chevron up icon
5. Ionic Directives and Services Chevron down icon Chevron up icon
6. Building a Bookstore App Chevron down icon Chevron up icon
7. Cordova and ngCordova Chevron down icon Chevron up icon
8. Building a Messaging App Chevron down icon Chevron up icon
9. Releasing the Ionic App Chevron down icon Chevron up icon
A. Additional Topics and Tips Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4
(14 Ratings)
5 star 64.3%
4 star 21.4%
3 star 7.1%
2 star 0%
1 star 7.1%
Filter icon Filter
Top Reviews

Filter reviews by




An engineer's engineer Aug 11, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Solid tech book. Great overview of Ionic, and my favorite part is the AngularJS primer.
Amazon Verified review Amazon
Zoryana Tischenko Jan 17, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Easy to follow examples, compact and digestible writing. Code submitted for each chapter and each chapter accompanied with link to its git repo.
Amazon Verified review Amazon
PaloAltan Sep 29, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Unlike so many of the recent titles in the crush to exploit the popularity of AngularJS and Ionic, this author has a truly deep understanding of AngularJS and Ionic. I bought the book because I follow the author's "Jackal of JavaScript" blog closely. If you're new to Ionic, this is the best thing out there right now...
Amazon Verified review Amazon
james t. leveille Feb 01, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book!
Amazon Verified review Amazon
Leigh Millard Sep 01, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
After deciding to take the leap from web development to hybrid mobile app development I was find the answers I needed through my standard learning channels of online videos and forums.This book has helped me enormously. It is clear, concise and makes learning the Ionic framework so much easier than muddling through contradictory examples and demo's online.As well as covering the Ionic framework the book also covers Cordova and helps the reader understand how the two technologies work together and which tool is best for the particular action you wish to perform.The book itself follows the Ionic learning curve in a logical step by step manor with easy to understand examples and great downloadable code snippets to back up the examples and help you on your way.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.