Learning AngularJS

Book description

With AngularJS, you can quickly build client-side applications that run well on any desktop or mobile platform, using REST web services for backend processes. You may have heard that the learning curve for this JavaScript MVC framework is too steep, but that’s not the case. This practical guide provides a hands-on approach to learning AngularJS that will have you building high-quality applications and websites in no time.

Along with a conceptual understanding of the framework, you’ll also gain direct experience with AngularJS by building a sample application throughout the book. If you’re familiar with JavaScript, web development, and software design concepts and patterns, this book is the perfect way to get started.

  • Understand how AngularJS differs from other MVC frameworks
  • Learn about AngularJS controllers, views, and models by diving into the book’s sample project
  • Connect your working application to public REST services
  • Build the application’s security layer with non-REST AngularJS services
  • Explore the basics of building and testing AngularJS directives
  • Use AngularJS as part of the MEAN stack (MongoDB, ExpressJS, AngularJS, and Node.js)
  • Discover how search engine optimization relates to AngularJS applications and sites

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Why I Wrote This Book
    2. What This Book Covers
    3. Who Should Read This Book
    4. The Chapters in This Book
    5. Conventions Used in This Book
    6. Using Code Examples
    7. Safari® Books Online
    8. How to Contact Us
  2. 1. Introduction to AngularJS
    1. JavaScript Client-Side Frameworks
    2. Single-Page Applications
    3. Bootstrapping the Application
    4. Dependency Injection
    5. AngularJS Routes
    6. HTML5 Mode
    7. Modern Search Engines
    8. AngularJS Templates
    9. AngularJS Views (MVC)
    10. AngularJS Models (MVC)
    11. AngularJS Controllers (MVC)
    12. Controller Business Logic
    13. Integrating AngularJS with Other Frameworks
    14. Testing AngularJS Applications
    15. Conclusion
  3. 2. The IDE and AngularJS Projects
    1. The IDE
    2. Editing the HTML Code
    3. Editing the JavaScript Code
    4. Creating the Templates
    5. Running the Applications
    6. Testing AngularJS Applications in the IDE
    7. JsTestRunner
    8. Karma Test Runner
    9. Protractor
    10. Conclusion
  4. 3. MVC and AngularJS
    1. The Old Way
      1. Choice One
      2. Choice Two
    2. A New and Better Way
    3. Testing Considerations
    4. Responsive Design Considerations
    5. Conclusion
  5. 4. AngularJS Controllers
    1. Initializing the Model with Controllers
    2. Adding Behavior with Controllers
    3. Controller Business Logic
    4. Presentation Logic and Formatting Data
    5. Form Submission
    6. Using Submitted Form Data
    7. JS Test Driver
      1. Creating Test Scripts
      2. Testing with JS Test Driver
    8. Testing with Karma
      1. Installing Karma
      2. Karma Configuration
      3. Running Karma Unit Tests
    9. End-to-End Testing with Protractor
      1. Installing Protractor
      2. Configuring Protractor
      3. Creating Protractor Test Specifications
      4. Starting the Selenium Server
      5. Running Protractor
    10. Conclusion
  6. 5. AngularJS Views and Bootstrap
    1. AngularJS Templates
    2. Creating the Blog Project
    3. Adding a New Blog Controller
    4. Adding a New Blog Template
    5. Twitter Bootstrap
    6. Adding a Bootstrap Menu
    7. Adding Mock Blog Data
    8. Using CSS3 to Style the Page
    9. Adding Styles and Presentation Logic
    10. Viewing the Blog Post
    11. Running the Blog Application
    12. Testing with Karma
      1. Karma Configuration
      2. Karma Test Specifications
      3. Karma Testing
    13. End-to-End Testing
      1. Protractor Test Specification
      2. Protractor Testing
    14. Conclusion
  7. 6. AngularJS and REST Services
    1. REST Services
    2. AngularJS and REST Services
    3. Ways to Create AngularJS Services
    4. Ways to Communicate with REST Services
    5. Updating the Project for REST
    6. REST Services and Controllers
    7. The JSON Response
    8. List Services
    9. Testing Services with Karma
      1. Karma Service Specifications
    10. End-to-End Testing
      1. Protractor Configuration
      2. Protractor Test Specification
    11. Conclusion
  8. 7. AngularJS Models
    1. Public REST Services
    2. Changes to the Controllers
    3. Model Properties
    4. Blog Application Public Services
    5. Modifying the HTML
    6. Modifying App.js
    7. Modifying the Controllers
    8. Running the Application
    9. Testing Services with Karma
      1. Karma Service Specifications
      2. Karma Testing
    10. End-to-End Testing
      1. Protractor Test Specification
      2. Protractor Testing
    11. Conclusion
  9. 8. Services and Business Logic
    1. Handling User Authentication
    2. Using Basic Authentication
    3. Creating AngularJS Services
    4. Holding User Credentials
    5. Checking User Credentials
    6. Deleting User Credentials
    7. Retrieving User Credentials
    8. Blog Application Business Logic
    9. Using the Business Logic
    10. Testing Services with Karma
      1. Karma Configuration
      2. Karma Test Specifications
      3. Karma Testing
    11. End-to-End Testing
    12. Protractor Configuration
    13. Protractor Test Specification
    14. Protractor Testing
    15. Conclusion
  10. 9. AngularJS Directives
    1. The HTML Compiler
    2. What Are Directives?
    3. Building Custom Directives
    4. Naming Conventions for Directives
    5. The Restrict Option
    6. The Template URL
    7. Template Attributes
    8. Adding the Custom Directive
    9. Passing the Title Attribute
    10. Running the Blog Application
    11. Testing Directives with Karma
      1. Karma Configuration
      2. Karma Test Specification
      3. Karma Testing
    12. End-to-End Testing
      1. Protractor Configuration
      2. Protractor Test Specification
      3. Protractor Testing
    13. Conclusion
  11. 10. AngularJS Security
    1. Authentication
    2. Adding a Login Service
    3. Adding a Login Controller
    4. Security Modifications to Other Controllers
    5. Adding a Logout Controller
    6. Adding a Login Template
    7. Adding New Routes
    8. Adding a Logout Link
    9. Running the Blog Application
      1. Logging In
    10. Testing with Karma
      1. Karma Configuration
      2. Karma Test Specifications
      3. Karma Testing
    11. End-to-End Testing
      1. Protractor Configuration
      2. Protractor Test Specification
      3. Protractor Testing
    12. One Last Point on Security
    13. Conclusion
  12. 11. MEAN Cloud and Mobile
    1. Local Deployment
    2. Installing Node.js, npm, and MongoDB
    3. Installing the NetBeans Node.js Plugin
    4. The MEAN Application
    5. Node.js Public Folder
    6. MEAN Services
    7. MEAN Blog Controllers
    8. MEAN Blog Templates
    9. Adding Comments
    10. Adding Blog Entries
    11. Adding New Routes
    12. Adding Node.js Dependencies
    13. Running the Blog Application Locally
    14. Testing with Karma
      1. Karma Configuration
      2. Karma Test Specifications
      3. Karma Testing
    15. End-to-End Testing
      1. Protractor Configuration
      2. Protractor Test Specification
      3. Protractor Testing
    16. MEAN Deployment to the Cloud
    17. Testing the Cloud Blog
    18. Mobile Version
    19. Conclusion
  13. 12. AngularJS and SEO
    1. Old Versus New AngularJS SEO
    2. Getting Found by Search Engines
    3. Google Webmaster Tools
    4. Adding a Sitemap
    5. Microformat Tags
    6. Building Clean Client Code
    7. Building Fast REST Services
    8. Conclusion
  14. References
  15. Index

Product information

  • Title: Learning AngularJS
  • Author(s): Ken Williamson
  • Release date: March 2015
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781491916704