The world of mobile development is fragmented, with many platforms, frameworks, and technologies. Ionic is intended to fill that gap, with its open source HTML5 mobile app framework that lets developers build native-feeling apps using web technologies such as HTML, CSS, and AngularJS. Ionic makes it easy for frontend developers to become app developers. The framework provides superior performance with deep Cordova integration and a comprehensive set of tools for prototyping, backend support, and deployment.
This book will take you through the process of developing a cross-platform mobile app using just HTML5 and Javascript based on Ionic 2, which is the latest version of Ionic using the Angular 2 framework. You will start by getting familiar with the CLI and learning how to build and run an app. You will touch on common features of real-world mobile applications, such as authenticating a user, getting data, and saving data using either Firebase or local storage. Next, the book will explain how Ionic integrates with Cordova to support native device features using ngCordova and take advantage of the existing modules around its ecosystem. You will also explore advanced topics of extending Ionic to create new components. Finally, the book will show you how to customize the Ionic theme and build an app for all platforms.
Chapter 1, Creating Our First App with Ionic 2, introduces the Ionic 2 framework with instructions on how to set up the development environment and quickly create and run your first app.
Chapter 2, Adding Ionic 2 Components, walks you through some examples of how to manage pages, states, and the overall navigation within the app.
Chapter 3, Extending Ionic 2 with Angular 2 Building Blocks, takes a deep dive into the AngularJS components, directives, and the customization of pipes. You will learn how to leverage the Ionic 2 module architecture to create shared services.
Chapter 4, Validating Forms and Making HTTP Requests, explains how to create a complex form with input validation, retrieve data via REST API calls, and integrate with Stripe for online payment.
Chapter 5, Adding Animation, provides instructions on how to embed a video as background, create a physics-based CSS animation, and bind gestures to the animation state.
Chapter 6, User Authentication and Push Notification Using Ionic Cloud, takes a deep dive into registering and authenticating users using Ionic Cloud and sending and receiving push notifications.
Chapter 7, Supporting Device Functionalities Using Ionic Native, explains how to use Ionic Native to access native device functionalities, such as camera, social sharing, InAppBrowser, and map.
Chapter 8, Theming the App, provides instructions on how to customize the app for different platforms using Sass variables.
Chapter 9, Publishing the App for Different Platforms, looks into the process of performing the final steps of getting the app published.
A Mac computer with Mac OS X El Capitan and root privileges
iPhone 5 or later version
Any Android device with Android 5.x or later version (optional)
Any Windows Phone device (optional)
Ionic 2 Cookbook is intended for frontend developers who want to take advantage of their existing skills to develop cross-platform mobile apps. This book will help you become an intermediate or advanced Ionic Framework developer by covering topics about AngularJS, Cordova, and Sass in depth. Since Ionic is open source, there is a large community supporting this framework for you to continue the learning journey.
In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).
To give clear instructions on how to complete a recipe, we use these sections as follows:
This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.
This section usually consists of a detailed explanation of what happened in the previous section.
This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "There is no need to modify the /platforms
or /plugins
folder manually unless troubleshooting needs to be done."
A block of code is set as follows:
<ion-tabs> <ion-tab [root]="tab1Root" tabTitle="One" tabIcon="water"></ion-tab> <ion-tab [root]="tab2Root" tabTitle="Two" tabIcon="leaf"></ion-tab> <ion-tab [root]="tab3Root" tabTitle="Three" tabIcon="flame"></ion-tab> </ion-tabs>
Any command-line input or output is written as follows:
$ sudo npm install -g cordova ionic ios-sim
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "In this section, you will learn how to create an attribute directive that can prevent certain characters from being input in the Username as well as showing another DOM node (where it says You are typing username) by toggling its visibility."
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>
, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
Log in or register to our website using your e-mail address and password.
Hover the mouse pointer on the SUPPORT tab at the top.
Click on Code Downloads & Errata.
Enter the name of the book in the Search box.
Select the book for which you're looking to download the code files.
Choose from the drop-down menu where you purchased this book from.
Click on Code Download.
You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR / 7-Zip for Windows
Zipeg / iZip / UnRarX for Mac
7-Zip / PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Ionic-2-Cookbook. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/Ionic2Cookbook_ColorImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of the existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>
, and we will do our best to address the problem.