Copyright
Table of Contents
Preface
Conventions Used in This Book
Using Code Examples
Safari® Books Online
How to Contact Us
Acknowledgments
Chapter 1. Introduction to AngularJS
Concepts
Client-Side Templates
Model View Controller (MVC)
Data Binding
Dependency Injection
Directives
An Example: Shopping Cart
Up Next
Chapter 2. Anatomy of an AngularJS Application
Invoking Angular
Loading the Script
Declaring Angular’s Boundaries with ng-app
Model View Controller
Templates and Data Binding
Displaying Text
Form Inputs
A Few Words on Unobtrusive JavaScript
Lists, Tables, and Other Repeated Elements
Hiding and Showing
CSS Classes and Styles
Considerations for src and href Attributes
Expressions
Separating UI Responsibilities with Controllers
Publishing Model Data with Scopes
Observing Model Changes with $watch
Performance Considerations in watch()
Organizing Dependencies with Modules
How Many Modules Do I Need?
Formatting Data with Filters
Changing Views with Routes and $location
index.html
list.html
detail.html
controllers.js
Talking to Servers
Changing the DOM with Directives
index.html
controllers.js
Validating User Input
Moving On
Chapter 3. Developing in AngularJS
Project Organization
Tools
IDEs
Running Your Application
With Yeoman
Without Yeoman
Testing with AngularJS
Karma
Unit Tests
End-to-End/Integration Tests
Compilation
Other Awesome Tools
Debugging
Batarang
Yeoman: Optimizing Your Workflow
Installing Yeoman
Starting a Fresh AngularJS project
Running Your Server
Adding New Routes, Views, and Controllers
The Testing Story
Building Your Project
Integrating AngularJS with RequireJS
Chapter 4. Analyzing an AngularJS App
The Application
Relationship Between Model, Controller, and Template
The Model
Controllers, Directives, and Services, Oh My!
Services
Directives
Controllers
The Templates
The Tests
Unit Tests
Scenario Tests
Chapter 5. Communicating with Servers
Communicating Over $http
Configuring Your Request Further
Setting HTTP Headers
Caching Responses
Transformations on Requests and Responses
Unit Testing
Working with RESTful Resources
The Declaration
Custom Methods
No Callbacks! (Unless You Really Want Them)
Simplified Server-Side Operations
Unit Test the ngResource
The $q and the Promise
Response Interception
Security Considerations
JSON Vulnerability
XSRF
Chapter 6. Directives
Directives and HTML Validation
API Overview
Naming Your Directive
The Directive Definition Object
Transclusion
Compile and Link Functions
Scopes
Manipulating DOM Elements
Controllers
Moving On
Chapter 7. Other Concerns
$location
HTML5 Mode and Hashbang Mode
AngularJS Module Methods
Where’s the Main Method?
Loading and Dependencies
Convenience Methods
Communicating Between Scopes with $on, $emit, and $broadcast
Cookies
Internationalization and Localization
What Can I Do in AngularJS?
How Do I Get It All Working?
Common Gotchas
Sanitizing HTML & the Sanitize Module
Linky
Chapter 8. Cheatsheet and Recipes
Wrapping a jQuery Datepicker
ng-model
Binding select
Calling select
The Rest of the Example
The Teams List App: Filtering and Controller Communication
The Search Box
The Combo Boxes
The Check Box
The Repeater
File Upload in AngularJS
Using Socket.IO
A Simple Pagination Service
Working with Servers and Login
Conclusion
Index
About the Authors