In Ember.js
, a service is a long-lived Ember object that can be available in different parts of your application. The following syntax is used to create the Ember.js
service.
Syntax :
"ember. Service"​
Following is a list of some examples of
Ember.js
services :
* Logging
* User/session authentication
* Geolocation
* Third-party API's
* Web Sockets
* Server sent events or notifications
* Server-backed API calls that may not fit ember-data etc.
Ember CLI service generator is used to generate the service. To get access to a service, inject
it either in an initializer or use the following syntax :
By using this method, you can also access the properties and methods using services.
Use the following syntax to define a service.
Syntax :
ember generate service service_name;