gokatz
2/19/2016 - 5:46 AM

service inj

service inj

{
  "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"
  }
}
import Ember from 'ember';

export default Ember.Service.extend({
  name: 'CodeX',
  //product: ['mobile software', 'web development', 'wed design']
});
import Ember from 'ember';

let mixin = Ember.Mixin.create({
	product: ['mobile software', 'web development', 'wed design'], 
  contact: 'gokul@codex.com'
});

export default mixin;
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');
  }
};
<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>
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
  })
});