Angular 2


This book is no longer available for sale.

Angular 2

A Practical Introduction to the new Web Development Platform Angular 2 (Angular.js, Angular.js 2, AngularJS, AngularJS 2, ng2)

About the Book

This book will be updated continuously to new releases of Angular 2. 

Learn to write Angular 2 applications from scratch

In this book you'll learn everything about the new Angular 2 platform by following practical examples. This book starts from scratch and is suitable for beginners. No AngularJS 1.x knowledge is necessary. You just need to have a basic understanding of HTML and JavaScript to follow the easy and practical examples provided.

What is Angular 2?

Angular 2 is the next major version of Google's popular JavaScript-based web framework. Angular 2 is designed for building complex applications for the browser. In contrast to version 1.x, Angular 2 introduces a complete new concept of building web applications. In this book you will learn the basic concepts and explore the new building blocks of Angular by following the practical code examples. 

What you'll learn

This books guides you through all new aspects of Angular 2. You'll get a real-world understanding of how Angular 2 can be applied in your own web and mobile applications. You'll also learn the following:

  • How to build Angular 2 Components
  • Using Lifecycle Events to control your application state
  • Embedding Templates to create dynamic output
  • Implementing interactive Forms
  • Understanding and using Pipes
  • Using the new Angular 2 Routing System
  • Getting to know the concept of Dependency Injection & Services and use it in your Angular 2 application
  • Sending and receiving data by using the HTTP client

Updates for upcoming releases

This book will be updated to keep information up to date with new Angular 2 releases. 

Code Samples 

Code samples are provided in a GitHub repository to download and use for learning or within your own projects.

If you have any questions or comments, please don't hesitate to get in touch.

Book Sample / Preview

A book sample in PDF format can be downloaded here.

  • Share this book

  • Categories

    • AngularJS
    • JavaScript
    • Computers and Programming
  • Feedback

    Email the Author(s)

About the Author

Sebastian Eschweiler
Sebastian Eschweiler

Using and writing about best practices and latest technologies in web design & development is my passion. Check out my blog at

Table of Contents

  • Chapter 01: Introduction
    • Why Angular 2 Rocks
    • Who This Book Is For
    • Code Examples On GitHub
  • Chapter 02: Writing your First Angular 2 Application
    • Preparing your Development Environment
      • Installing Project Dependencies
      • TypeScript Compiler Configuration
      • SystemJS Configuration
    • Implementation
      • Implementing AppModule
      • Implementing AppComponent
      • Implementing the View
      • Loading Components and Bootstrapping the Application
    • Running the Application
    • GitHub
  • Chapter 03: Modules, Components and Directives
    • Modules
      • Introduction to Angular 2 Modules Concept
      • Angular 2 Modules VS. ECMAScript 6 Modules
      • Application Module
      • Feature Modules
      • Angular 2 Standard Modules
    • Components
      • A Tree of Components - How to Structure your Application?
      • What About Modules?
      • Prepare the Project
      • Creating the Todo Data Model
      • Implementation of Component TodoItem
      • Implementation of Component TodosList
      • Implementation of AppComponent
      • Implementation of TodosModule and AppModule
      • Starting The Application
      • Implementation of Component AddTodo
      • Add Delete Functionality
    • Built-in Angular 2 Directives
      • What Are Built-in Directives?
      • NgIf
      • NgSwitch
      • NgStyle
      • NgClass
      • NgFor
      • NgNonBindable
    • GitHub
  • Chapter 04: Events
    • User Input Events
      • The $event Object
      • Local Template Variables
      • Event Filtering
    • Lifecycle Events
      • Bootstrapping the Application
      • Component Lifecycle
    • GitHub
  • Chapter 05: Forms
    • Template-driven Forms
      • Preparing the Project Structure
      • Implementing the Model
      • Create The Form Component
      • Form Template
      • Applying Two-Way Binding
      • Bootstrapping and Using Form Component
      • Form And Control State
      • Submitting The Form
    • GitHub
  • Chapter 06: Pipes
    • Usage of Pipes
    • Built-in Pipes
      • DecimalPipe
      • PercentPipe
      • CurrencyPipe
      • UpperCasePipe
      • LowerCasePipe
      • DatePipe
      • AsyncPipe
      • JsonPipe
      • SlicePipe
    • Custom Pipes
      • Implementing Custom Pipes
    • Pure And Impure Pipes
      • Pure Pipes
      • Impure Pipes
      • Comparing Pure And Impure Pipes
    • GitHub
  • Chapter 07: Routing
    • Sample Application of This Chapter
    • Setup and Configuration
      • Adding the Base Element
      • Router Configuration
    • Embed Route Output in Host View
    • Router Links
    • Data Service Implementation
    • Implementing CarsListComponent
    • Implementing CarDetailComponent
    • Implementing CarFormComponent
    • Implementing AboutComponent
    • Routing URL Styles
      • HTML 5 Style and Hash Location Style
      • Location Strategies
    • GitHub
  • Chapter 08: Dependency Injection and Services
    • Introduction
    • A First Example With Dependency Injection
    • Providers And Injectors
    • Using Injectors To Make Services Exchangeable
    • Types of Providers
      • Aliased Class Providers
      • Value Providers
      • Factory Providers
    • Injector Hierarchy
      • Root Injector
      • Module Injectors
      • Component Injectors
      • Resolving of Dependencies
      • Singleton Behavior
    • GitHub
  • Chapter 09: Http Service
    • Introduction
    • Using the Angular 2 Http Client
      • Importing HttpModule
      • Injecting The Http Service
      • Creating a Client Model
    • Setting Up a Rest Back-end
    • Fetching Data
    • Using the Asynchronous Observable Pattern with RxJS
      • Mapping the Response Object
      • Error Handling
      • Using the subscribe Function
    • Sending Data
    • Promises
    • GitHub

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub