Skip to content

Instantly share code, notes, and snippets.

@sbounmy
Last active August 29, 2015 14:28
Show Gist options
  • Save sbounmy/b5cb246f24f45ddfb55d to your computer and use it in GitHub Desktop.
Save sbounmy/b5cb246f24f45ddfb55d to your computer and use it in GitHub Desktop.
injection to helpers
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
export default Ember.Helper.extend({
compute: function(params) {
console.log(this.get('application'));
return 'hello ' + params[0] + ' from ' + this.get('application.currentRouteName');
}
});
export default {
name: 'my-t-injection',
initialize: function(registry, application) {
console.log(registry.lookup('controller:application'));
application.register('helper:my-t', 'application', 'controller:application');
}
};
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{my-t 'world'}}
{{outlet}}
<br>
<br>
{
"version": "0.4.8",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.8/ember.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.9/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.8/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment