Ember.inject.service()

service (name) Ember.InjectedPropertypublic

Defined in packages/ember-runtime/lib/system/service.js:5
Available since 1.10.0

Creates a property that lazily looks up a service in the container. There are no restrictions as to what objects a service can be injected into.

Example:

App.ApplicationRoute = Ember.Route.extend({
  authManager: Ember.inject.service('auth'),

  model: function() {
    return this.get('authManager').findCurrentUser();
  }
});

This example will create an authManager property on the application route that looks up the auth service in the container, making it easily accessible in the model hook.

Parameters:

name String
(optional) name of the service to inject, defaults to the property's name

Returns:

Ember.InjectedProperty
injection descriptor instance
doc_EmberJs
2016-11-30 16:51:30
Comments
Leave a Comment

Please login to continue.