{"action":"created","issue":{"url":"https://api.github.com/repos/emberjs/ember.js/issues/11021","labels_url":"https://api.github.com/repos/emberjs/ember.js/issues/11021/labels{/name}","comments_url":"https://api.github.com/repos/emberjs/ember.js/issues/11021/comments","events_url":"https://api.github.com/repos/emberjs/ember.js/issues/11021/events","html_url":"https://github.com/emberjs/ember.js/issues/11021","id":73117344,"number":11021,"title":"Inject into a helper","user":{"login":"atomkirk","id":2091439,"avatar_url":"https://avatars.githubusercontent.com/u/2091439?v=3","gravatar_id":"","url":"https://api.github.com/users/atomkirk","html_url":"https://github.com/atomkirk","followers_url":"https://api.github.com/users/atomkirk/followers","following_url":"https://api.github.com/users/atomkirk/following{/other_user}","gists_url":"https://api.github.com/users/atomkirk/gists{/gist_id}","starred_url":"https://api.github.com/users/atomkirk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atomkirk/subscriptions","organizations_url":"https://api.github.com/users/atomkirk/orgs","repos_url":"https://api.github.com/users/atomkirk/repos","events_url":"https://api.github.com/users/atomkirk/events{/privacy}","received_events_url":"https://api.github.com/users/atomkirk/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-05-04T20:19:57Z","updated_at":"2015-12-04T14:59:23Z","closed_at":"2015-06-30T17:40:05Z","body":"I have this:\r\n\r\n```\r\nexport function initialize(container, application) {\r\n    application.inject('component', 'store', 'store:main');\r\n    application.inject('component', 'application', 'application:main');\r\n    application.inject('component', 'applicationController', 'controller:application');\r\n    application.inject('helper', 'applicationController', 'controller:application');\r\n    application.inject('model:device', 'application', 'application:main');\r\n    application.inject('model:room', 'application', 'application:main');\r\n    application.inject('model:setting', 'application', 'application:main');\r\n    application.inject('route:application', 'application', 'application:main');\r\n    application.inject('transform', 'application', 'application:main');\r\n}\r\n\r\nexport default {\r\n  name: 'injections',\r\n  initialize: initialize\r\n};\r\n```\r\n\r\nnotice:\r\n\r\n```\r\napplication.inject('helper', 'applicationController', 'controller:application');\r\n```\r\n\r\nbut in the helper, `this.get('applicationController')` is not defined:\r\n\r\n```\r\nimport Ember from 'ember';\r\nimport environment from '../utils/environment';\r\n\r\nexport function staticImg(path, options) {\r\n    if (path) {\r\n        var staticRoot = this.get('applicationController').get('model.staticRoot');\r\n        return new Ember.Handlebars.SafeString('<img src=\"' + environment.staticHost() + staticRoot + path + '\" class=\"' + ( options.hash.classNames || \"\" ) + '\">');\r\n    }\r\n    else {\r\n        return \"\";\r\n    }\r\n}\r\n\r\nexport default Ember.Handlebars.makeBoundHelper(staticImg);\r\n```\r\n\r\nIn the docs it says you can inject onto helpers, and this exact setup working on other framework classes but not here…"},"comment":{"url":"https://api.github.com/repos/emberjs/ember.js/issues/comments/161987298","html_url":"https://github.com/emberjs/ember.js/issues/11021#issuecomment-161987298","issue_url":"https://api.github.com/repos/emberjs/ember.js/issues/11021","id":161987298,"user":{"login":"rwjblue","id":12637,"avatar_url":"https://avatars.githubusercontent.com/u/12637?v=3","gravatar_id":"","url":"https://api.github.com/users/rwjblue","html_url":"https://github.com/rwjblue","followers_url":"https://api.github.com/users/rwjblue/followers","following_url":"https://api.github.com/users/rwjblue/following{/other_user}","gists_url":"https://api.github.com/users/rwjblue/gists{/gist_id}","starred_url":"https://api.github.com/users/rwjblue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwjblue/subscriptions","organizations_url":"https://api.github.com/users/rwjblue/orgs","repos_url":"https://api.github.com/users/rwjblue/repos","events_url":"https://api.github.com/users/rwjblue/events{/privacy}","received_events_url":"https://api.github.com/users/rwjblue/received_events","type":"User","site_admin":false},"created_at":"2015-12-04T14:59:22Z","updated_at":"2015-12-04T14:59:22Z","body":"For anyone coming across this later, helpers in Ember 2.x are now \"real\" objects and can have access to services (via `Ember.inject.service` or initializer based injections).\r\n\r\nExample:\r\n\r\n```javascript\r\nexport default Ember.Helper.extend({\r\n  i18n: Ember.inject.service('i18n'),\r\n\r\n  compute(params, hash) {\r\n    let i18n = this.get('i18n');\r\n    // stuff here\r\n  }\r\n});\r\n```"}}