Skip to content

Instantly share code, notes, and snippets.

@thousand
Last active March 28, 2019 04:33
Show Gist options
  • Select an option

  • Save thousand/a17798e7b7dac2f835c85127488cd3ef to your computer and use it in GitHub Desktop.

Select an option

Save thousand/a17798e7b7dac2f835c85127488cd3ef to your computer and use it in GitHub Desktop.
foobar
import Ember from 'ember';
export default Ember.Component.extend({
fooBar: Ember.inject.service('foo-bar'),
});
import Ember from 'ember';
export default Ember.Component.extend({
fooBar: Ember.inject.service('foo-bar'),
foo: Ember.computed.alias('fooBar.foo'),
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
fooBar: Ember.inject.service('foo-bar'),
});
import Ember from 'ember';
export default Ember.Service.extend({
foo: 0,
bar: 0,
fooPlus(x) {
this.incrementProperty('foo');
console.log('foo', this.get('foo'))
},
barPlus(x) {
this.incrementProperty('bar');
console.log('bar', this.get('bar'))
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<table>
<tr>
<td>
<h2>Foo</h2>
{{fooBar.foo}}
{{x-foo bump=(action fooBar.fooPlus)}}
</td>
<td>
<h2>Bar</h2>
{{fooBar.bar}}
{{x-bar bump=(action fooBar.barPlus)}}
</td>
</tr>
</table>
{{yield}}
{{fooBar.bar}}
<button {{action bump}}>Bump</button>
{{yield}}
{{foo}}
<button {{action bump}}>Bump</button>
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment