Skip to content

Instantly share code, notes, and snippets.

@jrowlingson
Created November 4, 2016 15:05
Show Gist options
  • Save jrowlingson/cf213b295e240209cbf0cf0c097195d9 to your computer and use it in GitHub Desktop.
Save jrowlingson/cf213b295e240209cbf0cf0c097195d9 to your computer and use it in GitHub Desktop.
computed
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
_foo: 'foo',
foo: Ember.computed({
get() {
return this.get('_foo');
},
set(key, value) {
return this.set('_foo', value);
}
}),
actions: {
update() {
this.set('foo', 'bar');
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{foo}}
<br>
<button {{action 'update'}}>update</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