万本电子书0元读

万本电子书0元读

顶部广告

Learning Angular 2电子书

售       价:¥

0人正在读 | 0人评论 9.8

作       者:Pablo Deeleman

出  版  社:Packt Publishing

出版时间:2016-05-31

字       数:256.5万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Your quick, no-nonsense guide to building real-world apps with Angular 2About This Book·The first and best overview of Angular 2 on the market—this guide gathers together everything there is to know about Angular 2 and groups it into intuitive sections.·This book is your detailed map of every feature and its use cases.·The author has done all the hard work of fitting everything Angular 2 means for developers together for you, making this book the quickest way to learn Angular 2 from scratch.Who This Book Is ForThis book is targeted at web developers who want to build the next generation of state-of-the-art mobile and desktop web applications with Angular 2. This book does not require you to have prior exposure to either Angular 1.x or 2, although comprehensive knowledge of JavaScript is assumed. It's great for newcomers to Angular who learn best through clear explanations and definitions of concepts.What You Will Learn·Set up your working environment in order to have all the tools you need to start building Angular 2 components with minimum effort·Get up to speed with TypeScript, a powerful typed superset of JavaScript that compiles to plain JavaScript·Take full control of how your data is rendered and updated upon data changes·Build powerful web applications based on structured component hierarchies that emit and listen to events and data changes throughout the elements tree·Explore how to consume external APIs and data services and allow data editing by harnessing the power of web forms made with Angular 2·Deliver seamless web navigation experiences with application routing and state handling common features with ease·Discover how to bulletproof your applications by introducing smart unit testing techniques and debugging toolsIn DetailAngular 2 was conceived as a complete rewrite in order to fulfill the expectations of modern developers who demand blazing fast performance and responsiveness from their web applications.This book will help you learn the basics of how to design and build Angular 2 components right from the beginning, providing full coverage of the TypeScript syntax required to follow the examples included. From that point on, we will build upon our first components, interconnect them, and give shape to larger web applications. We will then move to implementing routing in Angular 2, analyzing how to handle application states, and navigating from one component to another in depth. After this, the book features full coverage of web forms and user input validation, later leveraging all of this information to go through the basics of implementing user authentication in Angular 2 and providing a bird's eye view of the different strategies at hand to secure pages and areas of your website. Animating components and DOM elements with Angular 2 is also covered in this book. The final part of this book provides broad insights into how to unit test components and other modules such as services, directives, routes or pipes.Style and approachThis book covers everything there is to know about getting well-acquainted with Angular without bogging you down. Everything is neatly laid out under clear headings for quick consultation, offering you the information required to understand a concept immediately, with short relevant examples of each feature.
目录展开

Learning Angular 2

Learning Angular 2

Credits

About the Author

Acknowledgments

About the Reviewer

www.PacktPub.com

eBooks, discount offers, and more

Why subscribe?

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Errata

Piracy

Questions

1. Creating Our Very First Component in Angular 2

A fresh start

Web components

Why TypeScript over other syntaxes?

Setting up our workspace

Installing dependencies

Installing TypeScript

Installing TypeScript typings

Hello, Angular 2!

TypeScript classes

Introducing metadata decorators

Compiling TypeScript into browser-friendly JavaScript

The HTML container

Serving the examples of this book

Putting everything together

Enhancing our IDE

Sublime Text 3

Atom

Visual Studio Code

WebStorm

Leveraging Gulp with other IDEs

Diving deeper into Angular 2 components

Improving productivity

Component methods and data updates

Adding interactivity to the component

Improving the data output in the view and polishing the UI

Summary

2. Introducing TypeScript

Understanding the case for TypeScript

The benefits of TypeScript

Introducing TypeScript resources in the wild

The TypeScript official site

The TypeScript Wiki

Types in TypeScript

String

Declaring our variables the ECMAScript 6 way

Number

Boolean

Array

Dynamic typing with the any type

Enum

Void

Type inference

Functions, lambdas, and execution flow

Annotating types in our functions

Function parameters in TypeScript

Optional parameters

Default parameters

Rest parameters

Overloading the function signature

Better function syntax and scope handling with lambdas

Classes, interfaces, and class inheritance

Anatomy of a class – constructors, properties, methods, getters, and setters

Interfaces in TypeScript

Extending classes with class inheritance

Decorators in TypeScript

Class decorators

Extending the class decorator function signature

Property decorators

Method decorators

Parameter decorators

Organizing our applications with modules

Internal modules

External modules

The road ahead

Summary

3. Implementing Properties and Events in Our Components

A better template syntax

Data bindings with input properties

Some extra syntactic sugar when binding expressions

Event binding with output properties

Input and output properties in action

Setting up custom values declaratively

Communicating between components through custom events

Emitting data through custom events

Local references in templates

Alternative syntax for input and output properties

Configuring our template from our component class

Internal and external templates

Encapsulating CSS styling

The styles property

The styleUrls property

Inline style sheets

Managing view encapsulation

Summary

4. Enhancing Our Components with Pipes and Directives

Directives in Angular 2

Core directives

NgIf

NgFor

NgStyle

NgClass

NgSwitch, NgSwitchWhen, and NgSwitchDefault

Manipulating template bindings with Pipes

The uppercase/lowercase pipe

The number, percent, and currency pipes

The number pipe

The percent pipe

The currency pipe

The slice pipe

The date pipe

The JSON pipe

The replace pipe

The i18n pipes

The i18nPlural pipe

The i18nSelect pipe

The async pipe

Putting it all together in the Pomodoro task list

Setting up our main HTML container

Building our task list table with Angular directives

Toggling tasks in our task list

Displaying state changes in our templates

Embedding child components

Building our own custom pipes

Anatomy of a custom pipe

A custom pipe to better format time output

Filtering out data with custom filters

Building our own custom directives

Anatomy of a custom directive

Building a task tooltip custom directive

A word about naming conventions for custom directives and pipes

Summary

5. Building an Application with Angular 2 Components

Introducing the component tree

Common conventions for scalable applications

File and module naming conventions

Ensuring seamless scalability with facades or barrels

How dependency injection works in Angular 2

Injecting dependencies across the component tree

Restricting dependency injection down the component tree

Restricting provider lookup

Overriding providers in the injector hierarchy

Extending injector support to custom entities

Initializing applications with bootstrap()

Switching between development and production modes

Enabling Angular 2's built-in change detection profiler

Introducing the Pomodoro App directory structure

Refactoring our application the Angular 2 way

The shared context

Services in the shared context

Configuring application settings from a central service

Creating a facade module including a custom providers barrel

Creating our components

The timer context

The tasks context

Defining the top root component

Bootstrapping the application

Summary

6. Asynchronous Data Services with Angular 2

Strategies for handling asynchronous information

Observables in a nutshell

Reactive functional programming in Angular 2

The RxJS library

Introducing the HTTP API

When to use the Request and RequestOptionsArgs classes

The Response object

Handling errors when performing Http requests

Injecting the Http class and the HTTP_PROVIDERS modules symbol

A real case study – serving Observable data through HTTP

Adding tasks to our tasks service

Summary

7. Routing in Angular 2

Adding support for the Angular 2 router

Setting up the router service

Building a new component for demonstration purposes

Configuring the RouteConfig decorator with the RouteDefinition instances

The router directives – RouterOutlet and RouterLink

Triggering routes imperatively

CSS hooks for active routes

Handling route parameters

Passing dynamic parameters in our routes

Parsing route parameters with the RouteParams service

Defining child routers

Linking to child routes

The Router lifecycle hooks

The CanActivate hook

The OnActivate Hook

The CanDeactivate and OnDeactivate hooks

The CanReuse and OnReuse hooks

Advanced tips and tricks

Redirecting to other routes

Tweaking the base path

Finetuning our generated URLs with location strategies

Loading components asynchronously with AsyncRoutes

Summary

8. Forms and Authentication Handling in Angular 2

Two-way data binding in Angular 2

The NgModel directive

Binding a type to a form with NgModel

Bypassing the CanDeactivate router hook upon submitting forms

Tracking control interaction and validating input

Tracking changes with local references

Controls, ControlGroups, and the FormBuilder class

Introducing Controls and Validators

Controls in the DOM – the ngControl directive

Grouping controls in the DOM with NgControlGroup

Defining control groups imperatively with ControlGroup

Connecting the DOM and the controller with ngFormModel

A real example – our login component

The login feature context

The login form template

The login component

Applying custom validation to our controls

Watching state changes in our controls

Mocking a client authentication service

Exposing our new service to other components

Blocking unauthorized access

Making the UI reactive to the user authentication status

Running the extra mile on access management

Building our own secure RouterOutlet directive

Summary

9. Animating Components with Angular 2

Creating animations with plain vanilla CSS

Handling animation with CSS class hooks

Class hooks available

Animating components with the AnimationBuilder

The CssAnimationBuilder API

Tracking animation state with the Animation class

Developing custom animation directives

Interacting with our directive from the template

Looking into the future with ngAnimate 2.0

Summary

10. Unit testing in Angular 2

Why do we need tests?

Parts of a unit test in Angular 2

Dependency injection in unit tests

Setting up our test environment

Implementing our test runner

Setting up NPM commands

Angular 2 custom matcher functions

Testing pipes

Testing components

Testing components with dependencies

Overriding component dependencies for refined testing

Testing routes

Testing routes by URL

Testing redirections

Testing services

Testing asynchronous services

Mocking Http responses with MockBackend

Testing directives

The road ahead

Using Jasmine in combination with Karma

Introducing code coverage reports in your test stack

Implementing E2E tests

Summary

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部