Book Image

Angular 2 By Example

By : Chandermani Arora, Kevin Hennessy
Book Image

Angular 2 By Example

By: Chandermani Arora, Kevin Hennessy

Overview of this book

<p>Angular 2 will help you build faster, more efficient, and more flexible cross-platform applications. Angular 2 is known for taking the pain out of JavaScript development, and enabling more organized, readable, and testable code.</p> <p>This book builds three apps with varying degrees of complexity. It starts with a simple ‘Guess the Number’ game, which serves as a platform to launch you into the world of Angular. Next, you will learn to construct a popular ‘7-Minute Workout’ app, covering the building blocks of Angular. The final app, ‘Personal Trainer’ morphs the existing ‘7-Minute Workout’ into a full-fledged personal workout builder and runner, covering advanced directive building, which is the most fundamental and powerful feature of Angular.</p> <p>In addition to this, you will learn about testability and the framework constructs Angular provides to effectively test your app. The book concludes by providing you with practical advice and useful tips that will come in handy as you build more and more apps with Angular.</p>
Table of Contents (14 chapters)
Angular 2 By Example
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface

Angular and server interactions


Any client-server interaction typically boils down to sending HTTP requests to a server and receiving responses from a server. For heavy JavaScript apps, we depend on the AJAX request/response mechanism to communicate with the server. To support AJAX-based communication, Angular provides the Angular HTTP module. Before we delve into the HTTP module, we need to set up our server platform that stores the data and allows us to manage it.

Setting up the persistence store

For data persistence, we use a document database called MongoDB (https://www.mongodb.org/), hosted over MongoLab (https://mongolab.com/), as our data store. The reason we zeroed in on MongoLab is that it provides an interface to interact with the database directly. This saves us the effort of setting up server middleware to support MongoDB interaction.

Note

It is never a good idea to expose the data store/database directly to the client. But in this case, since our primary aim is to learn about Angular...