Book Image

AngularJS Web Application Development Blueprints

By : Vinci J Rufus
Book Image

AngularJS Web Application Development Blueprints

By: Vinci J Rufus

Overview of this book

Table of Contents (17 chapters)
AngularJS Web Application Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

The most annoying part of using any website or web application is the time we wait for pages to load. Sure, everybody is working on making the Web fast, but those 2-3 seconds that it takes for a round trip to the server does not stop you from opening multiple tabs and often forgetting which tab you originally were on.

The rapid popularity of JavaScript frameworks and technologies such as AJAX clearly show the desperate need to save those 1 or 2, second-round trips to the server, and provide the users with a more desktop-like user experience.

About JavaScript MVC frameworks

These JavaScript frameworks aren't some new revolutionary technology or a new discovery; they are all still using the same old faithful JavaScript. These JavaScript frameworks merely provide a layer of abstraction (if I may) or a more Model-View-Controller-like architecture, so that we can be more productive while building apps and don't really have to worry about mundane things.

The credit for the rising popularity of these JavaScript frameworks would go to this surge of JavaScript-based highly interactive and rich Internet applications that nowadays do so much more than just displaying data received from a backend server. All of this is possible thanks to the modern day browser and their JavaScript engines that have become faster and powerful.

There has nearly been an explosion of these JavaScript MVC frameworks, and every other day, we see a new framework being launched. While most people consider Backbone.js or SproutCore to be one of the first JavaScript frameworks, I would say Ext JS by Sencha has been among the first JavaScript frameworks and one that is still being extensively used in the corporate world mainly to build finance apps. While Backbone.js and SproutCore were launched in 2010, Version 2.0 of Ext JS was launched towards the end of 2007.

AngularJS too was launched somewhere in 2010. Around the same time, other JavaScript frameworks were sprouting up. However, it is probably the fastest growing framework in terms of user adoption, mainly due to the "wow" factor and also the backing from the big G.

Each framework has its own pros and cons, and ideally the choice of the framework would depend on the nature of your project.

Note

http://www.todomvc.com/ is a very nice site to understand and compare the functioning of these JavaScript frameworks.

AngularJS is currently the most popular JavaScript MVC framework. Some of the reasons for this would be as follows:

  • It's among the simplest to learn

  • It follows some of the best software-engineering concepts, and is ideal to build large, scalable apps

  • It has a robust testing framework to run Unit tests and End-to-End tests, thus making it easy to write and run automated test cases

  • It also allows for teams to work in parallel on a single application without stepping over each other's work

  • It has the fastest growing community of adaptors, and the AngularJS Google Groups and IRC chats are a great place to interact with others

How AngularJS was born

AngularJS started as an internal Google project by Misko Hevery, sometime in 2009. As the story goes, Misko's team was working on a project called Google Feedback; even after six months of development and about 17,000 lines of code, they were still unhappy with the pace of development and the inability to write automated tests. That's when Misko decided to rewrite that. It took him about 3 weeks and he managed to write the whole thing in just about 1,500 lines of code.

That's when AngularJS got some serious attention internally at Google, and a team was put together to help further develop it. Around 2010, Google decided to declare it as open source under the MIT license.

The idea behind this book

The idea behind writing this book is to showcase the different types of applications that can be built on AngularJS. Besides explaining AngularJS and how to write modular and testable code, there is a fair amount of emphasis on making those apps look beautiful. So, be ready for some CSS stuff and design-related discussions.

I've tried to cover a variety of applications ranging from a simple address book, an HTML5 mobile app, an e-commerce store, a CMS framework, and also ideas on how to deploy apps on Amazon AWS.

What this book covers

This book is broken down into nine chapters.

Chapter 1, Introduction to AngularJS and the Single Page Application, talks about the concept of a Single Page App and how they are different from the regular web apps. We'll also learn about the basics of AngularJS by building a simple Address Book App.

Chapter 2, Setting Up Your Rig, talks about how having the right set of tools can be a huge productivity booster. It also makes you feel like a pro when building your AngularJS app. This chapter will talk about some of the tools such as Node.js, ExpressJS, Grunt, Yeoman, and Karma.

Chapter 3, Rapid Prototyping with AngularJS, talks about the ease with which one can create clickable prototypes to get a feel of how an application would look and feel before working on any backend code.

Chapter 4, Using REST Web Services in Your AngularJS App, will show you how to consume data from third-party REST web services using factories and the $http service.

Chapter 5, Facebook Friends' Birthday Reminder App, will explain directives and how we can create our Facebook login directive. We will also set up some automated tests to ensure everything is working fine.

Chapter 6, Building an Expense Manager Mobile App, will walk you through the process of building a responsive and touch-friendly mobile app using ngAnimate and HTML5 features such as localStorage.

Chapter 7, Building a CMS on the MEAN Stack, talks about how to set up an entire backend and frontend system and how AngularJS interacts with a node server and MongoDB database. We will also look at session management and interceptors.

Chapter 8, Scalable Architecture for Deployments on AWS, will teach you about AWS and its various services, and how we can deploy our app in a Server-less Architecture that can inherently scale.

Chapter 9, Building an E-Commerce Store, will show you how to directly read and write data from AWS's DynamoDB database, and upload images to S3 directly from our JavaScript app.

Appendix, AngularJS Resources. Well, you know what to expect here.

What you need for this book

You obviously don't need to read the entire book before you can start working on your first AngularJS project. I'm a firm believer of learning things the practical way, and that's why from the very first chapter, you will find yourself firing up your IDE/Text editor, and writing code and testing it on your browser.

While you will learn a couple of new features of AngularJS in each of the chapters, each chapter is still self-contained, and you can comfortably jump to any of the chapters that interest you or that you need to refer to for your project.

However, if you are just starting off with AngularJS, then I strongly recommend that you read through the first three chapters before you start jumping.

Software versions

The current stable version of AngularJS while writing this book is 1.2, and unless specified, we will be using the stable version of 1.2.17 for all the examples in this book.

You can get the latest version of AngularJS using any of the following methods:

Copying the code files

The code examples mentioned in this book can be used in your programs. However, if you choose to burn them on to CDs for redistribution or are putting up the code examples for downloads, you are required to get explicit permission from Packt Publishing.

Who this book is for

This book is mainly aimed at professionals, both designers and programmers. Thankfully, AngularJS is evolving to be a framework where both designers and programmers work together without discriminating each other as backend developers or frontend designers.

The book obviously assumes that you know your basics in HTML, CSS, and JavaScript. You understand the importance and need for writing modular, scalable, testable, and good-looking applications. You don't need to have worked with AngularJS or any other JavaScript framework to understand the topics covered. The book assumes you just met AngularJS on a blind date.

The book starts off with getting you comfortable with the basic concepts that you come across very often while working with AngularJS. We'll write some simple code just to see how AngularJS works, understanding it better, and then we'll graduate to writing cleaner and modular code.

Also, I have a chapter dedicated to setting up your development "rig" with a set of tools and plugins that will help you boost your productivity while building AngularJS apps.

Conventions

In this book, you will find a number of styles of text 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: "Now, angular-bootstrap will be available for use across our application."

A block of code is set as follows:

<carousel interval="setInterval">
   <slide ng-repeat="slide in slides" active="slide.active">
   </slide>
</carousel>

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

<body ng-app ng-init=" myName ='John Doe' ">
    {{myName}} is {{ 2014-1968}} years old.
    <script src=" angular.min.js " type="text/javascript "> </script>
</body>

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

yo angular:route subscribers

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the Download button and select the following options from the pop-up window:"

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 may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via 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 on 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 for all Packt books you have purchased 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.

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 would 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 on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright 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 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

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.