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
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781783552603
Vendor :
Drifty
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.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
€189.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
€264.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 98.97
Getting Started with Ionic
€24.99
Learning Ionic
€36.99
Ionic Cookbook
€36.99
Total 98.97 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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.