AngularJS

Book description

Develop smaller, lighter web apps that are simple to create and easy to test, extend, and maintain as they grow. This hands-on guide introduces you to AngularJS, the open source JavaScript framework that uses Model–view–controller (MVC) architecture, data binding, client-side templates, and dependency injection to create a much-needed structure for building web apps.

Table of contents

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

Product information

  • Title: AngularJS
  • Author(s):
  • Release date: April 2013
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449344856