Skip to content

Instantly share code, notes, and snippets.

@billdami
Created April 14, 2017 19:30
Show Gist options
  • Save billdami/b01f670d4a49c2e72a10f5dec4267d37 to your computer and use it in GitHub Desktop.
Save billdami/b01f670d4a49c2e72a10f5dec4267d37 to your computer and use it in GitHub Desktop.
Overwrite Computed Property
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
foo: 'foo',
bar: 'bar',
fooBar: Ember.computed('foo', 'bar', function() {
return this.get('foo') + this.get('bar');
}),
actions: {
overwrite: function() {
this.set('fooBar', 'something else');
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{input value=foo}}<br><br>
{{input value=bar}}
<br>
<br>
<button {{action "overwrite"}}>Overwrite computed property</button>
<p>
<code>foo</code> + <code>bar</code> = {{fooBar}}
</p>
{
"version": "0.12.1",
"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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment