-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inject into a helper #11021
Comments
You cannot inject into helpers. I believe that the docs have been updated, but please point me to where you noticed that it mentioned this was possible so we can fix the doc... |
Ah crap, you did update them for 1.11. Thanks. Ok, then what is the direction we should go if we need access to container stuff from within helpers and especially plain Ember.Object instances (which have no container property)? |
@atomkirk Instead of trying to inject something into a helper, you should inject into a controller/component and pass the injected object into the helper (or just use a computed property). Or just use a component instead of a helper. |
What if i am using helper inside component and i need to access user data too that i normally inject to routes and controllers ? It's not accessible inside that helper. |
This has been addressed in Ember.js 1.13 with closure actions. Please see: |
For anyone coming across this later, helpers in Ember 2.x are now "real" objects and can have access to services (via Example: export default Ember.Helper.extend({
i18n: Ember.inject.service('i18n'),
compute(params, hash) {
let i18n = this.get('i18n');
// stuff here
}
}); |
I have this:
notice:
but in the helper,
this.get('applicationController')
is not defined:In the docs it says you can inject onto helpers, and this exact setup working on other framework classes but not here…
The text was updated successfully, but these errors were encountered: