As we have discussed so far, a service is a single instance of an object, function, or value that you can leverage across the various components of your application. When you inject a service into an application, the
$inject service first looks to check if an instance of the service already exists. If it does, the
$inject service returns the existing instance. If it does not, the
$inject service creates a new instance of the service and returns it.
With this in mind, we can use one of five different module-definition methods to create our service. The first two are best for static values, configuration values, and models and the rest are best for defining services based on how they are constructed or used.