gokatz
2/22/2016 - 7:32 AM

utils injection

utils injection

var version = Em.inject.service();

var testfunction = function() {
  console.log(version);
	if(version <= 1)
  {
    return 'you must upgrade your app to continue';
  }
  else if(version > 1 && version <=2)
  {
  	return 'Try to upgrade your app asap. many feature may not work in this version';
  }
  else if(version > 2)
  {
    return 'Experience the Ultra-Fast Codex App';
  }
}

export default testfunction;
{
  "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": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.3.1/ember.debug.js",
    "ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js",
    "ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
  }
}
import Ember from 'ember';

export default Ember.Service.extend({
  version: 0.3,
});
var App = Ember.Application.create({});
export default {
  //name: 'store',
  //after: 'permission',
  initialize: function(container, application) {
    //application.inject('route', 'store', 'service:store');
    application.register('utils:test', App.test);
    application.inject('controller', 'version', 'service:version');
  }
};
<h1>Welcome to {{appName}}</h1>
<br>
{{bannerMsg}}

{{#if canCont}}
<button>Continue</button>
{{else}}
<button>Upgrade</button>
{{/if}}
<br>
{{outlet}}
<br>
<br>
import Ember from 'ember';
import upgradeMsg from 'demo-app/utils/test';
//import version from 'demo-app/services/version';

export default Ember.Controller.extend({
  appName:'CodeX',
  version: Em.inject.service(),
  canCont: Em.computed(function () {
  	if(this.get('version.version') <= 1)
    {
      return false;
    }
    else
    {
      return true;
    }
  }),
	bannerMsg: function() {
  	var version = this.get('version.version');
    //return upgradeMsg(version);
    return upgradeMsg();
  }.property(),
});