Angular 2 Cookbook

Discover over 70 recipes that provide the solutions you need to know to face every challenge in Angular 2 head on
Preview in Mapt

Angular 2 Cookbook

Matt Frisbie

1 customer reviews
Discover over 70 recipes that provide the solutions you need to know to face every challenge in Angular 2 head on
Mapt Subscription
FREE
$29.99/m after trial
eBook
$28.00
RRP $39.99
Save 29%
Print + eBook
$49.99
RRP $49.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$28.00
$49.99
$29.99 p/m after trial
RRP $39.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Angular 2 Cookbook Book Cover
Angular 2 Cookbook
$ 39.99
$ 28.00
Angular 2 Design Patterns and Best Practices Book Cover
Angular 2 Design Patterns and Best Practices
$ 35.99
$ 25.20
Buy 2 for $35.00
Save $40.98
Add to Cart

Book Details

ISBN 139781785881923
Paperback464 pages

Book Description

Angular 2 introduces an entirely new way to build applications. It wholly embraces all the newest concepts that are built into the next generation of browsers, and it cuts away all the fat and bloat from Angular 1. This book plunges directly into the heart of all the most important Angular 2 concepts for you to conquer. In addition to covering all the Angular 2 fundamentals, such as components, forms, and services, it demonstrates how the framework embraces a range of new web technologies such as ES6 and TypeScript syntax, Promises, Observables, and Web Workers, among many others.

This book covers all the most complicated Angular concepts and at the same time introduces the best practices with which to wield these powerful tools. It also covers in detail all the concepts you'll need to get you building applications faster. Oft-neglected topics such as testing and performance optimization are widely covered as well. A developer that reads through all the content in this book will have a broad and deep understanding of all the major topics in the Angular 2 universe.

Table of Contents

Chapter 1: Strategies for Upgrading to Angular 2
Introduction
Componentizing directives using controllerAs encapsulation
Migrating an application to component directives
Implementing a basic component in AngularJS 1.5
Normalizing service types
Connecting Angular 1 and Angular 2 with UpgradeModule
Downgrading Angular 2 components to Angular 1 directives with downgradeComponent
Downgrade Angular 2 providers to Angular 1 services with downgradeInjectable
Chapter 2: Conquering Components and Directives
Introduction
Using decorators to build and style a simple component
Passing members from a parent component into a child component
Binding to native element attributes
Registering handlers on native browser events
Generating and capturing custom events using EventEmitter
Attaching behavior to DOM elements with directives
Projecting nested content using ngContent
Using ngFor and ngIf structural directives for model-based DOM control
Referencing elements using template variables
Attribute property binding
Utilizing component lifecycle hooks
Referencing a parent component from a child component
Configuring mutual parent-child awareness with ViewChild and forwardRef
Configuring mutual parent-child awareness with ContentChild and forwardRef
Chapter 3: Building Template-Driven and Reactive Forms
Introduction
Implementing simple two-way data binding with ngModel
Implementing basic field validation with a FormControl
Bundling controls with a FormGroup
Bundling FormControls with a FormArray
Implementing basic forms with NgForm
Implementing basic forms with FormBuilder and formControlName
Creating and using a custom validator
Creating and using a custom asynchronous validator with Promises
Chapter 4: Mastering Promises
Introduction
Understanding and implementing basic Promises
Chaining Promises and Promise handlers
Creating Promise wrappers with Promise.resolve() and Promise.reject()
Implementing Promise barriers with Promise.all()
Canceling asynchronous actions with Promise.race()
Converting a Promise into an Observable
Converting an HTTP service Observable into a ZoneAwarePromise
Chapter 5: ReactiveX Observables
Introduction
Basic utilization of Observables with HTTP
Implementing a Publish-Subscribe model using Subjects
Creating an Observable authentication service using BehaviorSubjects
Building a generalized Publish-Subscribe service to replace $broadcast, $emit, and $on
Using QueryLists and Observables to follow changes in ViewChildren
Building a fully featured AutoComplete with Observables
Chapter 6: The Component Router
Introduction
Setting up an application to support simple routes
Navigating with routerLinks
Navigating with the Router service
Selecting a LocationStrategy for path construction
Building stateful route behavior with RouterLinkActive
Implementing nested views with route parameters and child routes
Working with matrix URL parameters and routing arrays
Adding route authentication controls with route guards
Chapter 7: Services, Dependency Injection, and NgModule
Introduction
Injecting a simple service into a component
Controlling service instance creation and injection with NgModule
Service injection aliasing with useClass and useExisting
Injecting a value as a service with useValue and OpaqueTokens
Building a provider-configured service with useFactory
Chapter 8: Application Organization and Management
Introduction
Composing package.json for a minimum viable Angular 2 application
Configuring TypeScript for a minimum viable Angular 2 application
Performing in-browser transpilation with SystemJS
Composing application files for a minimum viable Angular 2 application
Migrating the minimum viable application to Webpack bundling
Incorporating shims and polyfills into Webpack
HTML generation with html-webpack-plugin
Setting up an application with Angular CLI
Chapter 9: Angular 2 Testing
Introduction
Creating a minimum viable unit test suite with Karma, Jasmine, and TypeScript
Writing a minimum viable unit test suite for a simple component
Writing a minimum viable end-to-end test suite for a simple application
Unit testing a synchronous service
Unit testing a component with a service dependency using stubs
Unit testing a component with a service dependency using spies
Chapter 10: Performance and Advanced Concepts
Introduction
Understanding and properly utilizing enableProdMode with pure and impure pipes
Working with zones outside Angular
Listening for NgZone events
Execution outside the Angular zone
Configuring components to use explicit change detection with OnPush
Configuring ViewEncapsulation for maximum efficiency
Configuring the Angular 2 Renderer to use web workers
Configuring applications to use ahead-of-time compilation
Configuring an application to use lazy loading

What You Will Learn

  • Understand how to best move an Angular 1 application to Angular 2
  • Build a solid foundational understanding of the core elements of Angular 2 such as components, forms, and services
  • Gain an ability to wield complex topics such as Observables and Promises
  • Properly implement applications utilizing advanced topics such as dependency injection
  • Know how to maximize the performance of Angular 2 applications
  • Understand the best ways to take an Angular 2 application from TypeScript in a code editor to a fully function application served on your site
  • Get to know the best practices when organizing and testing a large Angular 2 application

Authors

Table of Contents

Chapter 1: Strategies for Upgrading to Angular 2
Introduction
Componentizing directives using controllerAs encapsulation
Migrating an application to component directives
Implementing a basic component in AngularJS 1.5
Normalizing service types
Connecting Angular 1 and Angular 2 with UpgradeModule
Downgrading Angular 2 components to Angular 1 directives with downgradeComponent
Downgrade Angular 2 providers to Angular 1 services with downgradeInjectable
Chapter 2: Conquering Components and Directives
Introduction
Using decorators to build and style a simple component
Passing members from a parent component into a child component
Binding to native element attributes
Registering handlers on native browser events
Generating and capturing custom events using EventEmitter
Attaching behavior to DOM elements with directives
Projecting nested content using ngContent
Using ngFor and ngIf structural directives for model-based DOM control
Referencing elements using template variables
Attribute property binding
Utilizing component lifecycle hooks
Referencing a parent component from a child component
Configuring mutual parent-child awareness with ViewChild and forwardRef
Configuring mutual parent-child awareness with ContentChild and forwardRef
Chapter 3: Building Template-Driven and Reactive Forms
Introduction
Implementing simple two-way data binding with ngModel
Implementing basic field validation with a FormControl
Bundling controls with a FormGroup
Bundling FormControls with a FormArray
Implementing basic forms with NgForm
Implementing basic forms with FormBuilder and formControlName
Creating and using a custom validator
Creating and using a custom asynchronous validator with Promises
Chapter 4: Mastering Promises
Introduction
Understanding and implementing basic Promises
Chaining Promises and Promise handlers
Creating Promise wrappers with Promise.resolve() and Promise.reject()
Implementing Promise barriers with Promise.all()
Canceling asynchronous actions with Promise.race()
Converting a Promise into an Observable
Converting an HTTP service Observable into a ZoneAwarePromise
Chapter 5: ReactiveX Observables
Introduction
Basic utilization of Observables with HTTP
Implementing a Publish-Subscribe model using Subjects
Creating an Observable authentication service using BehaviorSubjects
Building a generalized Publish-Subscribe service to replace $broadcast, $emit, and $on
Using QueryLists and Observables to follow changes in ViewChildren
Building a fully featured AutoComplete with Observables
Chapter 6: The Component Router
Introduction
Setting up an application to support simple routes
Navigating with routerLinks
Navigating with the Router service
Selecting a LocationStrategy for path construction
Building stateful route behavior with RouterLinkActive
Implementing nested views with route parameters and child routes
Working with matrix URL parameters and routing arrays
Adding route authentication controls with route guards
Chapter 7: Services, Dependency Injection, and NgModule
Introduction
Injecting a simple service into a component
Controlling service instance creation and injection with NgModule
Service injection aliasing with useClass and useExisting
Injecting a value as a service with useValue and OpaqueTokens
Building a provider-configured service with useFactory
Chapter 8: Application Organization and Management
Introduction
Composing package.json for a minimum viable Angular 2 application
Configuring TypeScript for a minimum viable Angular 2 application
Performing in-browser transpilation with SystemJS
Composing application files for a minimum viable Angular 2 application
Migrating the minimum viable application to Webpack bundling
Incorporating shims and polyfills into Webpack
HTML generation with html-webpack-plugin
Setting up an application with Angular CLI
Chapter 9: Angular 2 Testing
Introduction
Creating a minimum viable unit test suite with Karma, Jasmine, and TypeScript
Writing a minimum viable unit test suite for a simple component
Writing a minimum viable end-to-end test suite for a simple application
Unit testing a synchronous service
Unit testing a component with a service dependency using stubs
Unit testing a component with a service dependency using spies
Chapter 10: Performance and Advanced Concepts
Introduction
Understanding and properly utilizing enableProdMode with pure and impure pipes
Working with zones outside Angular
Listening for NgZone events
Execution outside the Angular zone
Configuring components to use explicit change detection with OnPush
Configuring ViewEncapsulation for maximum efficiency
Configuring the Angular 2 Renderer to use web workers
Configuring applications to use ahead-of-time compilation
Configuring an application to use lazy loading

Book Details

ISBN 139781785881923
Paperback464 pages
Read More
From 1 reviews

Read More Reviews

Recommended for You

Angular 2 By Example Book Cover
Angular 2 By Example
$ 35.99
$ 25.20
Angular Services Book Cover
Angular Services
$ 31.99
$ 22.40
Learning Angular 2 Book Cover
Learning Angular 2
$ 31.99
$ 22.40
Angular 2 Components Book Cover
Angular 2 Components
$ 23.99
$ 16.80
Mastering Angular 2 Components Book Cover
Mastering Angular 2 Components
$ 35.99
$ 25.20
ASP.NET Core and Angular 2 Book Cover
ASP.NET Core and Angular 2
$ 35.99
$ 25.20