AngularJS Services

Design, build, and test services to create a foundation for your AngularJS applications

AngularJS Services

Jim Lavin

Design, build, and test services to create a foundation for your AngularJS applications
Mapt Subscription
FREE
$29.99/m after trial
eBook
$11.90
RRP $16.99
Print + eBook
$26.99
RRP $26.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$11.90
$26.99
$29.99p/m after trial
RRP $16.99
RRP $26.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781783983568
Paperback152 pages

Book Description

This book provides you with the skills and best practices needed to create AngularJS services. It starts with the fundamentals of what services are and their role in a typical AngularJS application. You will walk through the development of a real-world application using services across the various application layers and then move on to create services that provide cross-cutting concerns such as messaging, logging, and authentication.

Next, the book covers services that provide data access showing you how to interact with external cloud-based data services and how to cache data on the client to reduce network latency. The book then shows you how to write services that leverage other cloud-based services to create mashups and include functionality in your application without writing a lot of code.

You will also learn how to create business logic objects, rules engines, and finite state machines, which can be used to provide business logic for your application.

Table of Contents

Chapter 1: The Need for Services
AngularJS best practices
Responsibilities of controllers
Responsibilities of directives
Responsibilities of services
Summary
Chapter 2: Designing Services
Measure twice, and cut once
Defining your service's interface
Designing for testability
Services, factories, and providers
Structuring your service in code
Configuring your service
Summary
Chapter 3: Testing Services
The basics of a test scenario
Loading your modules in a scenario
Mocking data
Mocking services
Mocking services with Jasmine spies
Handling dependencies that return promises
Mocking backend communications
Mocking timers
Summary
Chapter 4: Handling Cross-cutting Concerns
Communicating with your service's consumers using patterns
Managing user notifications
Logging application analytics and errors
Authentication using OAuth 2.0
Summary
Chapter 5: Data Management
Models provide the state and business logic
Implementing a CRUD data service
Caching data to reduce network traffic
Transforming data in the service
Summary
Chapter 6: Mashing in External Services
Storing events with Google Calendar
Using Google Tasks to build a brewing task list
Tying the Google Calendar and task list together
Summary
Chapter 7: Implementing the Business Logic
Encapsulating business logic in models
Encapsulating business logic in services
Models or services, which one to use?
Controlling a view flow with a state machine
Validating complex data with a rules engine
Summary
Chapter 8: Putting It All Together
Wiring in authentication
Displaying notifications and errors
Controlling the application flow
Displaying data from external services
Building and calculating the recipe
Messaging is the heart of the application
Summary

What You Will Learn

  • Write Jasmine scenarios to test your AngularJS services
  • Implement common functionality that can be leveraged by the controllers, directives, and other services in your application
  • Build services that create, retrieve, update, and delete your application's data on external servers
  • Incorporate third-party JavaScript libraries into your AngularJS application
  • Move business logic to the client side to build a new class of serverless applications
  • Optimize your AngularJS application for maximum performance

Authors

Table of Contents

Chapter 1: The Need for Services
AngularJS best practices
Responsibilities of controllers
Responsibilities of directives
Responsibilities of services
Summary
Chapter 2: Designing Services
Measure twice, and cut once
Defining your service's interface
Designing for testability
Services, factories, and providers
Structuring your service in code
Configuring your service
Summary
Chapter 3: Testing Services
The basics of a test scenario
Loading your modules in a scenario
Mocking data
Mocking services
Mocking services with Jasmine spies
Handling dependencies that return promises
Mocking backend communications
Mocking timers
Summary
Chapter 4: Handling Cross-cutting Concerns
Communicating with your service's consumers using patterns
Managing user notifications
Logging application analytics and errors
Authentication using OAuth 2.0
Summary
Chapter 5: Data Management
Models provide the state and business logic
Implementing a CRUD data service
Caching data to reduce network traffic
Transforming data in the service
Summary
Chapter 6: Mashing in External Services
Storing events with Google Calendar
Using Google Tasks to build a brewing task list
Tying the Google Calendar and task list together
Summary
Chapter 7: Implementing the Business Logic
Encapsulating business logic in models
Encapsulating business logic in services
Models or services, which one to use?
Controlling a view flow with a state machine
Validating complex data with a rules engine
Summary
Chapter 8: Putting It All Together
Wiring in authentication
Displaying notifications and errors
Controlling the application flow
Displaying data from external services
Building and calculating the recipe
Messaging is the heart of the application
Summary

Book Details

ISBN 139781783983568
Paperback152 pages
Read More

Read More Reviews