Getting Started with Ionic - Rahat Khanna - E-Book

Getting Started with Ionic E-Book

Rahat Khanna

0,0
26,39 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Get up and running with developing effective Hybrid Mobile Apps with Ionic

About This Book

  • Develop engaging mobile experiences with a native-looking UI in Ionic and AngularJS
  • Build mobile applications with a native UI and interactions with device APIs using popular web technologies such as HTML, CSS, and JavaScript
  • Create an e-commerce mobile app using tutorials and code samples

Who This Book Is For

This book is ideal for any web developer who wants to enter into the world of mobile app development but has no clue where to start. Ionic is an ideal starting point and provides a smooth learning curve to help you build hybrid apps using web technologies and to develop native apps for iOS and Android, you do not need to know multiple languages. This book will also be useful for Hybrid App developers who have not found the perfect framework to ensure users get a rich experience from your apps.

What You Will Learn

  • Get to know about Hybrid Apps and AngularJS
  • Set up a development environment to build Hybrid Apps
  • Navigate around the components and routing in Ionic
  • Use different Ionic directives for a mobile-specific experience
  • Integrate an Ionic App with backend web services
  • Work with plugins to include native functionality in your hybrid apps
  • Test your apps on real devices
  • Build an e-commerce app for iOS and Android from scratch

In Detail

Hybrid Apps are a promising choice in mobile app development to achieve cost effectiveness and rapid development. However, they were not preferred over native apps until few years back due to a poor performance and bad user experience, but everything has changed with the release of Ionic. It has evolved as the most popular choice for Hybrid Mobile App development as it tends to match the native experience and provides robust components/tools to build apps.

Getting Started with Ionic equips any web developer with the basic knowledge needed to use modern web technologies to build amazing hybrid mobile apps using Ionic.

This fast-paced, practical book explains all the important concepts of AngularJS and Cordova Framework required to develop apps, then gives you a brief introduction to hybrid mobile applications. It will guide you through setting up the environment to develop mobile apps, and through the multiple options and features available in Ionic so you can use them in your mobile apps. Features such as the Side Menu, Tabs, Touch Interactions, and native features such as Bar Code, Camera, and Geolocations are all covered.. Finally, we'll show you how to use Cordova plugins and publish your apps.

Style and approach

Getting started with Ionic is a compact, easy-to-follow guide to developing hybrid mobile apps using Ionic with real world examples of building an e-commerce app.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 193

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Getting Started with Ionic
Credits
Foreword
About the Author
About the Reviewer
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Running the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. All About Hybrid Mobile Apps and Ionic Framework
Introducing a Hybrid Mobile Application
Types of Hybrid Mobile Apps
WebView-based Hybrid Apps
Cross-compiled Hybrid Apps
Anatomy of a Hybrid Mobile App
Custom WebView
Native library
Native to JS Bridge
Using web technologies to develop for mobile
What is AngularJS?
Important concepts in AngularJS
Modules
Directives
Controllers
Services
Templates
Expressions
Filters
Why use Apache Cordova?
Introducing Ionic Framework
Summary
2. Setting up the Environment the Right Way
Setting up Native Mobile development environments
For iOS
Installing and running simulators for testing
For Android
Download links
Setting the environment variables
For Windows
For Linux/Mac OS
Managing Android SDK and emulators
Alternative to Android emulators – Genymotion
Ionic development environment
Installing NodeJS
Basic npm commands
Installing Cordova CLI and Ionic CLI
Installation command for Cordova CLI
Basic Ionic CLI commands
Building a dummy app
Popular issues faced and solutions
Alternative to installation fuss – Ionic Playground
Using Ionic Framework with different Code Editors
Brackets
Sublime Text
Visual Studio
Summary
3. Start Building Your First Ionic App
Starting a new project
Multiple ways to start a project
Method 1 – using CDN-hosted library files
Method 2 – using Ionic Creator to design a prototype and start a project
Method 3 – using Ionic CLI locally
The anatomy of Ionic Project
Project folder structure and important files
Main components
The index.html file
App.js and the root module
Simple content directives – ion-content and ion-pane
ion-content
ion-pane
The Ionic starter template
The blank template
The tabs template
The sidemenu template
The maps template
E-commerce sample app – BookStore
Features
Architecture and design
Summary
4. Navigation and Routing in an Ionic App
Introduction to Angular UI Router
States and URLs
Nested states and views
Using the dot notation
Using the parent property
Using object-based states
Views for nested views
Ways to transition to a state
Abstract state
Multiple and named views
View names – relative versus abstract
State parameters
Basic parameters
Regex parameters
Query parameters
Single parameter
Multiple parameters
The $stateParams service
State events and resolve
Resolve
Ionic header and footer
The <ion-header-bar> directive
The <ion-footer-bar> directive
Ionic Tabs
The <ion-tabs> directive
The <ion-tab> directive
Ionic side menu
The <ion-side-menus> directive
The <ion-side-menu> directive
The <ion-side-menu-content> directive
Other important directives
Navigation and back menus
Navigation and layout to be used in BookStore
Summary
5. Accessorizing Your App with Ionic Components
Ionic CSS components
Header
Footer
Buttons
Icon buttons
Button bar
Lists
List dividers
List icons
List buttons
Item avatars or thumbnails
Cards
Forms
Input elements
Checkbox
Radio button list
Toggle
Range
Tabs
Grid
Utility
Ionic JS components
Actionsheet – $ionicActionSheet
Backdrop - $ionicBackdrop
Form inputs
The <ion-checkbox> directive
The <ion-radio> directive
The <ion-toggle> directive
Gestures and events
The $ionicGesture service
The on method
The off method
Gesture events
Lists
The <ion-list> directive
Loading – $ionicLoading
Modal – $ionicModal
The IonicModal controller
initialize(options)
Popover – $ionicPopover
Spinner – ion-spinner
Miscellaneous components
$ionicPosition
$ionicConfigProvider
Summary
6. Integrating App with Backend Services
$http services
The response object
The $http constructor method
Ionic services vs factories
Ionic service – authentication service
Ionic factory – BooksFactory
$resource and REST API
Demystifying mBaaS
Integrating with Parse
Step 1 – creating an app on Parse
Step 2 – getting API keys
Step 3 – configuring appropriate settings
Step 4 – integrating SDK or integrating using REST API
Using SDK – downloading and overview
Using REST API
Integrating to Firebase
Summary
7. Testing App on Real Devices
Testing on browser emulators
Overview of device mode in Chrome dev tools
Ionic view app
The Ionic upload command
Viewing your app
Making debug build
Android debug build
iOS debug build
Remote debugging
Remote debugging using Chrome dev tools
Android debugging
iOS debugging
Remote debugging using jsconsole.com
Testing using Ngrok
Summary
8. Working with Cordova Plugins – ngCordova
Introduction to Cordova plugins
Plugin management
Integrating ngCordova to Ionic App
Important plugins
Camera plugin
Push Notifications
Geolocation
Contacts
Network
Device sensors
Device motion
Device orientation
Custom Cordova plugin development
Summary
9. Future of Ionic
Ionic cloud services
Ionic Creator
Ionic Market
Ionic Push
Ionic Deploy
Using Ionic Deploy
Ionic Analytics
Ionic Package
Ionic Lab
Ionic v2
New features
Angular 2, ES6, and Typescript
Abstracted annotations
Material design
Enhanced Native Integration
Powerful Theming
Improved navigation and routing
Migration to v2
Summary
Index

Getting Started with Ionic

Getting Started with Ionic

Copyright © 2016 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: January 2016

Production reference: 1070116

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78439-057-0

www.packtpub.com

Credits

Author

Rahat Khanna

Reviewer

Nikola Brežnjak

Commissioning Editor

Dipika Gaonkar

Acquisition Editor

Aaron Lazar

Content Development Editor

Priyanka Mehta

Technical Editor

Dhiraj Chandanshive

Copy Editor

Joanna McMahon

Project Coordinator

Izzat Contractor

Proofreader

Safis Editing

Indexer

Rekha Nair

Production Coordinator

Manu Joseph

Cover Work

Manu Joseph

Foreword

This book is the result of four months of intensive writing and coding on the part of Rahat Khanna, a dedicated Ionic community member, experienced developer, and excellent writer. We were really happy to hear that Rahat was writing an Ionic book because we think very highly of his blog posts, which have also been very popular among members of our developer community.

The book is ideal for new Ionic developers who have some prior web development experience. The book contains code samples related to a single app that readers build as they move from chapter to chapter.

In the first few chapters, Rahat offers a solid conceptual base for Angular and for Hybrid Mobile App development in general. He teaches users how to set up a native development environment and use the Ionic command-line interface.

In later chapters, Rahat takes a deep dive into Ionic's architecture and different components. Experienced Ionic developers will appreciate his chapters on integrating backend services and mBaaS with Ionic apps.

In addition, the book touches upon Ionic Platform Services and Ionic 2's new features and migration path.

By the time they complete this book, readers will be able to build a mobile application with a native-looking user interface and interactions with device APIs and publish it to the app stores.

I began my career as a developer and built many internal Hybrid Apps for my company. I chose Ionic because it offered the only complete solution for Hybrid Mobile App development, which allows me to focus on development; whereas Ionic handled architecture and design. Ionic offers a complete ecosystem to build performant, beautiful mobile apps using a single code base, which saves organization's both money and time and allows them to leverage the existing skills of their web developers.

As a core team member of Ionic and Ionic's developer advocate, I travel around the U.S. to speak about Ionic and teach developers how to use it. I hope that you find this book to be a great introduction to Ionic and also a way to build upon your existing skills.

Mike Harlington

Providence, Rhode Island

About the Author

Rahat Khanna is a techno-nerd experienced in developing web and mobile apps for many international MNCs and start-ups. He has completed his Bachelors in Technology with Computer Science & Engineering as specialisation. During the past 7 years, he has worked for a multinational IT service company and ran his own entrepreneurial venture also in his early twenties. He has worked on ranging projects from static HTML websites to scalable web applications and engaging mobile apps. Along with his current job as a Senior UI developer at Flipkart, a billion dollar e-commerce firm, he now blogs on the latest technology frameworks on sites www.airpair.com, appsonmob.com, and so on and delivers talks at community events. He has been helping individual developers and startups in their Ionic projects to deliver amazing mobile apps.

I live in Bangalore, India with my wife Palak who has been instrumental in motivating me to share my knowledge with the world and write this book. Also, I would like to thank my parents and family to support me in my endeavours. I would also like to thank Packt Publishing and their entire team for helping constantly throughout the whole experience of finishing the book. Finally, I am also indebted to all my career mentors and colleagues especially Sunil Khokhar and Rahul Luthra who have helped me in constantly learning new things and growing as a professional.

About the Reviewer

Nikola Brežnjak is an engineer at heart and a jack-of-all-trades kind of guy. For those who care about titles, he has a master's degree in computing. For the past eight years, he worked in the betting software industry where he made use of his knowledge in areas ranging from full stack (web and desktop) development to game development through Linux and database administration and use of various languages (C#, PHP, JavaScript to name just a few). Recently, he's been interested in the Ionic Framework, and he likes to help out on StackOverflow where he is currently in the top 0.X%.

He self-published the book Getting MEAN with MEMEs via Leanpub, available at https://leanpub.com/meantodo. Also, he self-published the book about Ionic Framework via Leanpub, https://leanpub.com/ionic-framework. He was a technical reviewer for the book Deploying Node.js, Sandro Pasquali, as well as for the video Beginning Ionic Hybrid Application Development, Troy Miles, both by Packt Publishing. You can find out more about him through his blog at http://www.nikola-breznjak.com/blog.

He lives in Croatia with his lovely wife and daughter whom he would like to thank to support him in all his geeky endeavors. Also, he would like to thank his parents to teach him the power of hard and consistent work.

www.PacktPub.com

Support files, eBooks, discount offers, and more

For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

Free access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

Preface

Hybrid Mobile Apps have become a promising choice in mobile app development to achieve cost effectiveness and rapid development. Ionic has been instrumental in setting the benchmark in this space as it focuses on performance. It has evolved as the most popular choice for Hybrid Mobile App development as it tends to match the native experience and provides robust components/tools to build apps.

Getting Started with Ionic equips any web developer with the practical knowledge required to use modern web technologies in building amazing Hybrid Mobile Apps using Ionic. This fast-paced, practical book explains all the important concepts of AngularJS and Cordova framework required to develop Ionic apps. Then, it gives you a brief introduction to Hybrid Mobile Applications. It will guide you through setting up the development environment for different mobile platforms and through the multiple options and features available in Ionic, so you can use them in your mobile apps. Features, such as the side menu, tabs, touch interactions, and native features, such as bar code, camera, and geolocations, are all covered. Finally, we'll show you how to use Cordova plugins and use Ionic cloud services to empower your mobile apps.

What this book covers

Chapter 1, All About Hybrid Mobile Apps and Ionic Framework, covers the introduction to Hybrid Mobile Applications and the technologies used to develop these apps. This chapter will also include all important concepts regarding AngularJS and Apache Cordova, which readers need to know before building Ionic apps.

Chapter 2, Setting up the Environment the Right Way, covers setting up the native development environments for required platforms and then installing Ionic and required dependencies to start building Ionic apps. It will include details about Ionic command-line interface and the important features it provides for rapid development.

Chapter 3, Start Building Your First Ionic App, includes instructions for starting a new project and leveraging Ionic starter templates to bootstrap easily. It also covers the explanation about the design of the app structure and how you can plan to develop your app on top of it.

Chapter 4, Navigation and Routing in an Ionic App, covers how to create routes and layouts for navigation. It will teach the reader about views, Ionic header/footer sections, and different layout components, such as tabs, side menu, and modals. It also includes the basic routes and navigation setup for our sample app.

Chapter 5, Accessorizing Your App with Ionic Components, covers different components, which will be used in building the mobile app. It has two major categories: one is CSS components, which include grid framework and some reusable CSS classes to be used to design UI. The other category is Javascript components, which will facilitate building the business logic and UI interactions for the app.

Chapter 6, Integrating App with Backend Services, includes explanation about creating Ionic services and factories, which will interact with backend services. Ionic Apps can be integrated with all kinds of web services, REST APIs, SOAP services, and even cloud-based mBaaS (Mobile Backend as a Services) such as Parse and Firebase.

Chapter 7, Testing App on Real Devices, covers tools and techniques used to test and debug the app on your actual devices.

Chapter 8, Working with Cordova Plugins - ngCordova, teaches the reader how to use ready-made Cordova plugins, which help the mobile app to talk to native device APIs, such as sensors, camera, and geolocation. It will also explain how to integrate an open source Angular wrapper named ngCordova for cordova plugins into an Ionic App.

Chapter 9, Future of Ionic, includes an introduction to various cloud Ionic services available online under the Ionic.io platform. It also covers about the future of Ionic v2 along with Angular v2 talking about new features and migration path.

What you need for this book

For this book, you require a system with Windows, Mac, or Linux OS. You need to install NodeJS and NPM to manage dependencies for different projects. This book will guide you through the setup for mobile app development platforms for iOS and Android. Test devices having Android and iOS would be required to test the mobile apps.

Who this book is for

This book is ideal for any web developer who wants to enter into the world of mobile app development but has no clue where to start. Ionic is an ideal starting point and provides a smooth learning curve to help you build Hybrid Apps using web technologies and to develop native apps for iOS and Android; you do not need to know multiple languages. This book will also be useful for Hybrid App developers who have not found the perfect framework to ensure that users get a rich experience from your apps.

Conventions

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, code tags, user input, and Twitter handles are shown in bold.

A block of code is set as follows:

<ion-nav-bar class="bar-stable"> <ion-nav-back-button> </ion-nav-back-button> </ion-nav-bar> <ion-nav-view></ion-nav-view>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<ion-nav-bar class="bar-stable"> <ion-nav-back-button> </ion-nav-back-button> </ion-nav-bar> <ion-nav-view></ion-nav-view>

Any command-line input or output is written as follows:

$ ionic start MenuDemo sidemenu

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 order to run an app on an Android device, enable Developer Options and check the USB Debugging option from the settings."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

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.

Customer support

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.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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.

Running the example code

The example codes available on the website are taken from Ionic Projects. In order to run them successfully on your machines, you need to create an empty Ionic Project and then copy the example code files to the www folder of your Ionic Project and then run npm install first and then ionic serve command to run locally or ionic run [android|ios] to run on the device.

Downloading the color images of this book

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 http://www.packtpub.com/sites/default/files/downloads/0570OS_ColorImages.pdf.

Errata

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 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

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.

Questions

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.

Chapter 1. All About Hybrid Mobile Apps and Ionic Framework

In this chapter, we are going to learn what a Hybrid Mobile Application is and the current technology ecosystems supporting it. We will also be introduced to Ionic Framework and the reasons that should lead you to decide on Ionic as your preferred choice. The topics covered in this chapter will be as follows:

Introduction to a Hybrid Mobile ApplicationUsing web technologies to develop for mobile devicesWhat is AngularJS?Why use Apache Cordova?Introducing Ionic Framework

The term 'website' has become a word of the past. 'App' is the new buzzword, and the world is moving away from old software systems to new jazzy apps. App, or application in terms of a software, is a more sophisticated system, which involves enabling a lot more features to the user rather than just providing static information like a traditional website.

Web apps have a lot of limitations such as requiring Internet connectivity all the time and restrictions on fully utilizing the hardware capabilities of the device on which you are accessing them. Mobile apps, on the other hand, defy all of these limitations and provide an engaging user experience.

Mobiles have emerged as the most popular channel for user engagement. The number of smartphone users is expected to grow to nearly 2.16 billion in 2016 (http://www.emarketer.com/Article/2-Billion-Consumers-Worldwide-Smartphones-by-2016/1011694), which is more than one quarter of the global population. The growth rate of smartphone usage has been tremendous and is expected to grow day by day.

Mobile adoption is associated with some of the following trivial points:

Mobiles are the only device that we keep with us the whole dayKids (between the ages of two and five) know more about using a smartphone than tieing their shoelaces