Last active
August 29, 2015 14:22
-
-
Save elidupuis/be03c8f209334a18b604 to your computer and use it in GitHub Desktop.
Ember inject POJO
This file contains 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
// app/initializers/foo.js | |
var POJO = { | |
bar: 'this is your POJO' | |
// whatever you need here | |
// this can also be import from another file... | |
}; | |
export function initialize(container, application) { | |
application.register('pojo:main', POJO, { instantiate: false, singleton: true }); | |
application.inject('route', 'foo', 'pojo:main'); | |
// application.inject('component', 'foo', 'pojo:main'); | |
// inject whereever you need it... | |
// then in your routes (or whereever) do: | |
// `this.foo` and you should have your POJO | |
} | |
export default { | |
name: 'foo', | |
initialize: initialize | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment