In Ember.js, a service is a singleton object that holds state. In other words, it can be shared throughout an Ember application and doesn't change. For example, session data, APIs that talk to a server, and WebSockets are good candidates for services.
In this recipe, we'll create and inject a service into a component.
Tip
Dependency injection
Services and dependency injection go hand in hand. Dependency Injection (DI) occurs when we take objects and inject them into other objects during instantiation. This means that we take a service and inject it into our routes, controllers, and components. This is an important framework concept and should not be overused. Having too many injected services would break the separation of concerns design principle.