Skip to content

Instantly share code, notes, and snippets.

@ctusch
Last active January 18, 2017 20:52
Show Gist options
  • Save ctusch/ea20786c96e6817b39d0335e321a81b8 to your computer and use it in GitHub Desktop.
Save ctusch/ea20786c96e6817b39d0335e321a81b8 to your computer and use it in GitHub Desktop.
Ember.Object with service
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this.set('someObject', Ember.getOwner(this).lookup('object:some-object'));
return this._super(...arguments);
}
});
export function initialize(application) {
application.registerOptionsForType('object', { singleton: false });
}
export default {
name: 'register-options',
initialize
};
import Ember from 'ember';
export default Ember.Object.extend({
someService: Ember.inject.service()
});
import Ember from 'ember';
export default Ember.Service.extend({
value: 3
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{someObject.someService.value}}
{{outlet}}
<br>
<br>
{
"version": "0.10.7",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.10.0",
"ember-data": "2.10.0",
"ember-template-compiler": "2.10.0",
"ember-testing": "2.10.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment