Skip to content

Instantly share code, notes, and snippets.

@gokatz
Last active February 19, 2016 06:59
Show Gist options
  • Save gokatz/94f13b6a2db325a313cd to your computer and use it in GitHub Desktop.
Save gokatz/94f13b6a2db325a313cd to your computer and use it in GitHub Desktop.
service inj
import Ember from 'ember';
import mixin from 'demo-app/mixins/apptest';
export default Ember.Controller.extend(mixin, {
appName: Ember.computed(function() {
return this.get('appname.name'); //service injected in intializers
}),
products: Ember.computed(function() {
return this.product; //mixin imported
}),
contactdetails: Ember.computed(function() {
return this.contact; ////mixin imported
})
});
<h1>Welcome to {{appName}}</h1>
<br>
<h3>Handling Projects Under </h3>
{{#each products as |product|}}
<li>{{product}}</li>
{{/each}}
<br>
contact us @ {{contactdetails}}
<br>
{{outlet}}
<br>
<br>
export default {
name: 'currentUser',
initialize: function(container, application) {
application.inject('controller', 'appname', 'service:appname');
//application.inject('controller', 'apptest', 'mixin:apptest');
application.inject('route', 'appname', 'service:appname');
}
};
import Ember from 'ember';
let mixin = Ember.Mixin.create({
product: ['mobile software', 'web development', 'wed design'],
contact: 'gokul@codex.com'
});
export default mixin;
import Ember from 'ember';
export default Ember.Service.extend({
name: 'CodeX',
//product: ['mobile software', 'web development', 'wed design']
});
{
"version": "0.5.3",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "1.13.13",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js",
"ember-template-compiler": "1.13.13"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment