Skip to content
This repository was archived by the owner on May 26, 2019. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,31 @@ Injections can be made onto all of Ember's major framework classes including com
-->

Dependency injection and service lookup are two powerful tools in your Ember.js toolset, and every mature Ember application will require their use.

### Dependency Injection with `Ember.Service`

```JavaScript
import Registry from "container/registry";
import Service from "ember-runtime/system/service";
import EmberObject from "ember-runtime/system/object";
import EmberRoute from "ember-routing/system/route";
import inject from "ember-runtime/inject";

var route = EmberRoute.create();
var registry = new Registry();
var container = registry.container();

registry.register('route:application', EmberRoute.extend({
authService: inject.service('auth')
}));

registry.register('service:auth', Service.extend());

var appRoute = container.lookup('route:application');
var authService = container.lookup('service:auth');

appRoute.get('authService')
```