O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Angular: Up and Running

Book Description

This book will demystify Angular as a framework, as well as provide clear instructions and examples on how to get started with writing scalable Angular applications.

Angular: Up & Running covers most of the major pieces of Angular, but in a structured manner that is generally used in hands-on training. Each chapter takes one concept, and use examples to cover how it works. Problems to work on (with solutions) at the end of each chapter reinforce the learnings of each chapter and allow readers to really get hands-on with Angular.

Table of Contents

  1. Introduction
    1. Who Should Read This Book
    2. Why I Wrote This Book
    3. A Word on Web Application Development Today
    4. Navigating This Book
    5. Online Resources
    6. Conventions Used in This Book
    7. Using Code Examples
    8. O’Reilly Safari
    9. How to Contact Us
    10. Acknowledgments
  2. 1. Introducing Angular
    1. Why Angular
    2. What This Book Will Not Cover
    3. Getting Started with Your Development Environment
      1. Node.js
      2. TypeScript
      3. Angular CLI
      4. Getting the Codebase
    4. Conclusion
  3. 2. Hello Angular
    1. Starting Your First Angular Project
    2. Understanding the Angular CLI
      1. Running the Application
    3. Basics of an Angular Application
      1. Root HTML—index.html
      2. The Entry Point—main.ts
      3. Main Module—app.module.ts
      4. Root Component—AppComponent
    4. Creating a Component
      1. Steps in Creating New Components
      2. Using Our New Component
      3. Understanding Data Binding
      4. Understanding Property Binding
      5. Understanding Event Binding
      6. Using Models for Cleaner Code
    5. Conclusion
    6. Exercise
  4. 3. Useful Built-In Angular Directives
    1. Directives and Components
    2. Built-In Attribute Directives
      1. NgClass
      2. NgStyle
      3. Alternative Class and Style Binding Syntax
    3. Built-In Structural Directives
      1. NgIf
      2. NgFor
      3. NgSwitch
      4. Multiple Sibling Structural Directives
    4. Conclusion
    5. Exercise
  5. 4. Understanding and Using Angular Components
    1. Components—A Recap
    2. Defining a Component
      1. Selector
      2. Template
      3. Styles
      4. Style Encapsulation
      5. Others
    3. Components and Modules
    4. Input and Output
      1. Input
      2. Output
      3. Change Detection
    5. Component Lifecycle
      1. Interfaces and Functions
    6. View Projection
    7. Conclusion
    8. Exercise
  6. 5. Testing Angular Components
    1. Why Unit Test?
    2. Testing and Angular
    3. The Test Setup
      1. Karma Config
      2. test.ts
    4. Writing Unit Tests
      1. An Isolated Unit Test
      2. Running the Tests
      3. Writing an Angular-Aware Unit Test
      4. Testing Component Interactions
    5. Debugging
    6. Conclusion
    7. Exercise
  7. 6. Working with Template-Driven Forms
    1. Template-Driven Forms
      1. Setting Up Forms
      2. Alternative to ngModel—Event and Property Binding
      3. ngModel
      4. A Complete Form
      5. Control State
      6. Control Validity
    2. Working with FormGroups
    3. Conclusion
    4. Exercise
  8. 7. Working with Reactive Forms
    1. Reactive Forms
      1. Understanding the Differences
    2. Using Reactive Forms
      1. Form Controls
      2. Form Groups
      3. Form Builders
    3. Form Data
      1. Control State, Validity, and Error Messages
      2. Form and Data Model
    4. FormArrays
    5. Conclusion
    6. Exercise
  9. 8. Angular Services
    1. What Are Angular Services?
    2. Creating Our Own Angular Service
      1. Digging into the Example
      2. An Introduction to Dependency Injection
      3. Angular and Dependency Injection
    3. RxJS and Observables: Moving to Asynchronous Operations
    4. Conclusion
    5. Exercise
  10. 9. Making HTTP Calls in Angular
    1. Introducing HttpClient
      1. Server Setup
      2. Using HttpClientModule
      3. Making HTTP GET/POST Calls
    2. Advanced HTTP
      1. Options—Headers/Params
      2. Options—Observe/Response Type
      3. Interceptors
    3. Advanced Observables
    4. Conclusion
    5. Exercise
  11. 10. Unit Testing Services
    1. How to Unit Test Services
    2. Testing Components with a Service Dependency
      1. Testing Components with a Real Service
      2. Testing Components with a Mock Service
      3. Testing Components with a Fake Service
    3. Unit Testing Async
    4. Unit Testing HTTP
    5. Conclusion
    6. Exercise
  12. 11. Routing in Angular
    1. Setting Up Angular Routing
      1. Server Setup
      2. Starting Codebase
      3. Importing the Router Module
      4. Displaying the Route Contents
      5. Navigating Within the Application
      6. Wildcards and Defaults
    2. Common Routing Requirements
      1. Required Route Params
      2. Navigating in Your Application
      3. Optional Route Params
    3. Route Guards
      1. Authenticated-Only Routes
      2. Preventing Unload
      3. Preloading Data Using Resolve
    4. Conclusion
    5. Exercise
  13. 12. Productionizing an Angular App
    1. Building for Production
      1. Production Build
      2. Ahead-of-Time (AOT) Compilation and Build Optimizer
      3. Base Href
      4. Deploying an Angular Application
    2. Other Concerns
      1. Caching
      2. API/Server Calls and CORS
      3. Different Environments
      4. Handling Deep-Linking
      5. Lazy Loading
      6. Server-Side Rendering and Handling SEO
    3. Conclusion
  14. Index