What are models and services?

Before we start digging into the technical underpinnings of how services work in angularjs and all of the amazing things you can do with them, we need to agree on some semantics. The phrase service is admittedly an overloaded term in angularjs that can lead to some confusion, especially if you’re coming from other languages. Technically, a service in angularjs is any piece of common functionality that can be shared across your entire application. In quite a few other languages, a “service” refers to a mechanism that communicates with a remote service, whereas a “model” is responsible for not only communicating with the remote service but managing the state surrounding that data.

a service may or may not communicate with a remote service, but it’s available to provide some functionality to the application. It’s a service to the application, and one or more of these services may contain the model on which the application relies for its data. We’ll refer to any service that communicates with a remote service and manages that state as a moidel

 

Chapter 2 of 6