You are previewing Pro AngularJS.
O'Reilly logo
Pro AngularJS

Book Description

AngularJS is the leading framework for building dynamic JavaScript applications that take advantage of the capabilities of modern browsers and devices. AngularJS, which is maintained by Google, brings the power of the Model-View-Controller (MVC) pattern to the client, providing the foundation for complex and rich web apps. It allows you to build applications that are smaller, faster, and with a lighter resource footprint than ever before.

Best-selling author Adam Freeman explains how to get the most from AngularJS. He begins by describing the MVC pattern and the many benefits that can be gained from separating your logic and presentation code. He then shows how you can use AngularJS's features within in your projects to produce professional-quality results. Starting from the nuts-and-bolts and building up to the most advanced and sophisticated features AngularJS is carefully unwrapped, going in-depth to give you the knowledge you need.

Each topic is covered clearly and concisely and is packed with the details you need to learn to be truly effective. The most important features are given a no-nonsense in-depth treatment and chapters include common problems and details of how to avoid them.

What you'll learn

  • Gain a solid architectural understanding of the MVC Pattern to separate logic, data and presentation code.

  • Learn how to create rich and dynamic web apps using AngularJS

  • Understand how each feature works and why it is important

  • Understand how to extend HTML with declarative syntax

  • Learn how to extend and customize AngularJS

  • Learn how to test, refine, and deploy your AngularJS projects

Who this book is for

This book is ideal for web developers who have a working knowledge of JavaScript, HTML and CSS. The book is platform agnostic and a range of browsers will be presented and discussed throughout the examples.

Table of Contents

  1. Title Page
  2. Dedication
  3. Contents at a Glance
  4. Contents
  5. About the Author
  6. About the Technical Reviewer
  7. PART 1: Getting Ready
    1. CHAPTER 1: Getting Ready
      1. What Do You Need to Know?
      2. What Is the Structure of This Book?
      3. Are There Lots of Examples?
      4. Where Can You Get the Example Code?
      5. How Do You Set Up Your Development Environment?
      6. Summary
    2. CHAPTER 2: Your First AngularJS App
      1. Preparing the Project
      2. Using AngularJS
      3. Going Beyond the Basics
      4. Summary
    3. CHAPTER 3: Putting AngularJS in Context
      1. Understanding Where AngularJS Excels
      2. Understanding the MVC Pattern
      3. Understanding RESTful Services
      4. Common Design Pitfalls
      5. Summary
    4. CHAPTER 4: HTML and Bootstrap CSS Primer
      1. Understanding HTML
      2. Understanding Bootstrap
      3. Summary
    5. CHAPTER 5: JavaScript Primer
      1. Preparing the Example Project
      2. Understanding the Script Element
      3. Using Statements
      4. Defining and Using Functions
      5. Using Variables and Types
      6. Using JavaScript Operators
      7. Working with Arrays
      8. Comparing undefined and null Values
      9. Working with Promises
      10. Working with JSON
      11. Summary
    6. CHAPTER 6: SportsStore: A Real Application
      1. Getting Started
      2. Displaying the (Fake) Product Data
      3. Displaying the Category List
      4. Summary
    7. CHAPTER 7: SportsStore: Navigation and Checkout
      1. Preparing the Example Project
      2. Using the Real Product Data
      3. Creating Partial Views
      4. Creating the Cart
      5. Adding URL Navigation
      6. Starting the Checkout Process
      7. Summary
    8. CHAPTER 8: SportsStore: Orders and Administration
      1. Preparing the Example Project
      2. Getting Shipping Details
      3. Placing Orders
      4. Making Improvements
      5. Administering the Product Catalog
      6. Summary
  8. PART 2: Working with AngularJS
    1. CHAPTER 9: The Anatomy of an AngularJS App
      1. Preparing the Example Project
      2. Working with Modules
      3. Using Modules to Define AngularJS Components
      4. Using Modules to Organize Code
      5. Summary
    2. CHAPTER 10: Using Binding and Template Directives
      1. Why and When to Use Directives
      2. Preparing the Example Project
      3. Using the Data Binding Directives
      4. Using the Template Directives
      5. Summary
    3. CHAPTER 11: Using Element and Event Directives
      1. Preparing the Example Project
      2. Using the Element Directives
      3. Handling Events
      4. Managing Special Attributes
      5. Summary
    4. CHAPTER 12: Working with Forms
      1. Preparing the Example Project
      2. Using Form Elements with Two-Way Data Bindings
      3. Validating Forms
      4. Providing Form Validation Feedback
      5. Using the Form Directive Attributes
      6. Summary
    5. CHAPTER 13: Using Controllers and Scopes
      1. Why and When to Use Controllers and Scopes
      2. Preparing the Example Project
      3. Understanding the Basics
      4. Organizing Controllers
      5. Using Scope-less Controllers
      6. Explicitly Updating the Scope
      7. Summary
    6. CHAPTER 14: Using Filters
      1. Why and When to Use Filters
      2. Preparing the Example Project
      3. Filtering Single Data Values
      4. Filtering Collections
      5. Chaining Filters
      6. Creating Custom Filters
      7. Summary
    7. CHAPTER 15: Creating Custom Directives
      1. Why and When to Create Custom Directives
      2. Preparing the Example Project
      3. Creating a Custom Directive
      4. Working with jqLite
      5. Replacing jqLite with jQuery
      6. Summary
    8. CHAPTER 16: Creating Complex Directives
      1. Preparing the Example Project
      2. Defining Complex Directives
      3. Using Directive Templates
      4. Managing Directive Scopes
      5. Summary
    9. CHAPTER 17: Advanced Directive Features
      1. Preparing the Example Project
      2. Using Transclusion
      3. Using Controllers in Directives
      4. Creating Custom Form Elements
      5. Summary
  9. PART 3: AngularJS Services
    1. CHAPTER 18: Working with Modules and Services
      1. Why and When to Use and Create Services and Modules
      2. Preparing the Example Project
      3. Using Modules to Structure an Application
      4. Creating and Using a Service
      5. Using the Built-in Modules and Services
      6. Summary
    2. CHAPTER 19: Services for Global Objects, Errors, and Expressions
      1. Preparing the Example Project
      2. Accessing the DOM API Global Objects
      3. Dealing with Exceptions
      4. Working with Dangerous Data
      5. Working with AngularJS Expressions and Directives
      6. Summary
    3. CHAPTER 20: Services for Ajax and Promises
      1. Why and When to Use the Ajax Services
      2. Preparing the Example Project
      3. Making Ajax Requests
      4. Working with Promises
      5. Summary
    4. CHAPTER 21: Services for REST
      1. Why and When to Use the REST Services
      2. Preparing the Example Project
      3. Using the $http Service
      4. Hiding the Ajax Requests
      5. Summary
    5. CHAPTER 22: Services for Views
      1. Why and When to Use the View Services
      2. Preparing the Example Project
      3. Using URL Routing
      4. Using Route Parameters
      5. Configuring Routes
      6. Summary
    6. CHAPTER 23: Services for Animation and Touch
      1. Preparing the Example Project
      2. Animating Elements
      3. Supporting Touch Events
      4. Summary
    7. CHAPTER 24: Services for Provision and Injection
      1. Why and When to Use the Provision and Injection Services
      2. Preparing the Example Project
      3. Registering AngularJS Components
      4. Managing Injection
      5. Summary
    8. CHAPTER 25: Unit Testing
      1. Why and When to Unit Testing
      2. Preparing the Example Project
      3. Working with Karma and Jasmine
      4. Understanding the Mock Objects
      5. Testing a Controller
      6. Using the Mock Objects
      7. Testing Other Components
      8. Summary
  10. Index