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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.