Book Image

PhoneGap and AngularJS for Cross-platform Development

By : Yuxian E Liang
Book Image

PhoneGap and AngularJS for Cross-platform Development

By: Yuxian E Liang

Overview of this book

PhoneGap is a mobile development framework that allows developers to build cross-platform mobile applications. Building PhoneGap apps is traditionally done using HTML, CSS, jQuery Mobile, Eclipse Editor, and/or Xcode. The process can be cumbersome, from setting up your editor to optimizing your usage of jQuery, and so on. However, AngularJS, a new but highly popular JavaScript framework, eases these tasks with APIs to get access to mobile APIs such as notifications, geo-location, accelerometers, and more. Starting with the absolute basics of building an AngularJS application, this book will teach you how to quickly set up PhoneGap apps using the command-line interface. You will learn how to create simple to advanced to-do lists and add authentication capabilities using PhoneGap's plugins. You will enhance your skills by writing a PhoneGap app using your newly learned AngularJS skills. Furthermore, you will learn about adding animation and interactive designs to your mobile web apps using PhoneGap plugins. By the end of the book, you will know everything you need to launch your app on both Android and iOS devices.
Table of Contents (14 chapters)
PhoneGap and AngularJS for Cross-platform Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Wiring up a backend server


In this section, we will make use of the $http module of AngularJS to make RESTful calls to a simple backend server. The backend server here is based on Facebook's Tornado Framework (https://github.com/facebook/tornado/), but the fact is that you can make RESTful calls using Express.js (http://expressjs.com/) or any other framework that you like.

Before you get started with this section, you will need to have MongoDB (http://www.mongodb.org/), Python 2.7.x, and the Tornado web server installed. You will also need to install a Python library called tornado-cor (https://github.com/globocom/tornado-cors), which facilitates the use of cross-origin resources between your AngularJS app and server.

Coding our server

The main idea of the Python Tornado server is as follows:

  • We have one endpoint, where this endpoint will receive a GET or POST request from our AngularJS app.

  • Depending on the URL argument received, the corresponding handler will perform GET on all to-do items...