home
  • Blog
  • Home
  • Projects
    • Ember
    • EmberData
    • Ember CLI
1.13
  • Packages
    • ember
    • ember-application
    • ember-debug
    • ember-extension-support
    • ember-htmlbars
    • ember-metal
    • ember-routing
    • ember-routing-htmlbars
    • ember-routing-views
    • ember-runtime
    • ember-templates
    • ember-testing
    • ember-views
  • Namespaces
    • Ember
    • Ember.FEATURES
    • Ember.String
    • Ember.computed
    • Ember.inject
    • Ember.run
  • Classes
    • Ember.Application
    • Ember.Array
    • Ember.ArrayProxy
    • Ember.Binding
    • Ember.Checkbox
    • Ember.Component
    • Ember.ComputedProperty
    • Ember.ContainerDebugAdapter
    • Ember.Controller
    • Ember.ControllerMixin
    • Ember.CoreObject
    • Ember.DataAdapter
    • Ember.DefaultResolver
    • Ember.Error
    • Ember.Evented
    • Ember.Helper
    • Ember.InstrumentationSupport
    • Ember.Logger
    • Ember.Mixin
    • Ember.MutableArray
    • Ember.MutableEnumerable
    • Ember.Namespace
    • Ember.NativeArray
    • Ember.Object
    • Ember.Observable
    • Ember.PromiseProxyMixin
    • Ember.Route
    • Ember.Router
    • Ember.Service
    • Ember.Test
    • Ember.Test.Adapter
    • Ember.Test.QUnitAdapter
    • Ember.TextArea
    • Ember.TextField
    • Ember.VisibilitySupport
    • RSVP.EventTarget
    • RSVP.Promise

Class Ember.inject public


Defined in: packages/ember-runtime/lib/inject.js:6
Module: ember

Namespace for injection helper methods.


Methods

controller (name) : Ember.InjectedProperty public

Module: ember

Defined in packages/ember-runtime/lib/controllers/controller.js:25

Available since v1.10.0

name
String

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

returns
Ember.InjectedProperty

injection descriptor instance

Creates a property that lazily looks up another controller in the container. Can only be used when defining another controller.

Example:

App.PostController = Ember.Controller.extend({
  posts: Ember.inject.controller()
});

This example will create a posts property on the post controller that looks up the posts controller in the container, making it easy to reference other controllers. This is functionally equivalent to:

App.PostController = Ember.Controller.extend({
  needs: 'posts',
  posts: Ember.computed.alias('controllers.posts')
});

service (name) : Ember.InjectedProperty public

Module: ember

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

Available since v1.10.0

name
String

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

returns
Ember.InjectedProperty

injection descriptor instance

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.

On this page


Methods

  • controller
  • service
Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2025 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue Created with Sketch.