Chapter 5AngularJS Services, Factories, and Providers

We've already mentioned services several times in the last few chapters. You have already used several built-in AngularJS services like $location, $timeout, $rootScope etc. But, in a real world application, the built-in services are not always going to be sufficient so you'll need to create custom services. This chapter will give you a comprehensive guide to three critical components of AngularJS: services, factories, and providers.

The main purpose of these components is that they hold some logic that's required at multiple points within your app. Although services, factories and providers are all used to accomplish the same task (encapsulating repetitive logic), there are subtle differences ...

Get AngularJS: Novice to Ninja now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.