Skip to content

Instantly share code, notes, and snippets.

@phillipkregg
Created October 24, 2016 15:15
Show Gist options
  • Save phillipkregg/2f9ef04ee90288f220409ff0e2adada7 to your computer and use it in GitHub Desktop.
Save phillipkregg/2f9ef04ee90288f220409ff0e2adada7 to your computer and use it in GitHub Desktop.
Nesting Services
import Ember from 'ember';
export default Ember.Controller.extend({
myService: Ember.inject.service('nested-folder/my-service'),
appName: 'Ember Twiddle',
actions: {
testService() {
this.get('myService').myFunction();
}
}
});
import Ember from 'ember';
export default Ember.Service.extend({
myFunction() {
alert('service works!');
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<button {{action 'testService'}}>Test Nested Service Folder</button>
{
"version": "0.10.6",
"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.9.0",
"ember-data": "2.9.0",
"ember-template-compiler": "2.9.0",
"ember-testing": "2.9.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment