Chapter 4. Models and services

This chapter covers

  • The vital role that models and services play
  • Different types of services and how to create them
  • Using $http to communicate with remote servers
  • How promises handle asynchronous communication
  • Using $http interceptors
  • How to use decorators to enhance services
  • Testing models and services

If a controller is supposed to be lightweight and only concern itself with the view it’s controlling, what happens when you need functionality to be available to your entire application? If a controller should never communicate directly with other controllers, how do they share information? Whereas controllers are constrained to a specific context, AngularJS services exist to provide functionality that’s ...

Get AngularJS in Action 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.