Created
April 1, 2014 02:40
-
-
Save jdjkelly/9906676 to your computer and use it in GitHub Desktop.
Ember App Kit Initializer Example for Injecting Current User into Controllers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Session from 'appkit/models/session'; | |
export default Ember.Application.initializer({ | |
name: 'currentUser', | |
initialize: function(container, app) { | |
// Register a new container | |
container.register('session:current-user', Session); | |
// Load the current user | |
container.lookup('session:current-user').find(); | |
// Inject the container into the controller | |
// containername object name factory | |
app.inject('controller', 'currentUser', 'session:current-user'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment