Skip to content

Instantly share code, notes, and snippets.

@spinlock99
Last active May 24, 2017 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save spinlock99/34b109a0eb6f0582a42bbddf68a3c165 to your computer and use it in GitHub Desktop.
Save spinlock99/34b109a0eb6f0582a42bbddf68a3c165 to your computer and use it in GitHub Desktop.
Computed Property
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Route.extend({
bar: 'baz',
foo: Ember.computed('bar', function () {
return this.get('bar');
}),
model: function () {
return this.get('foo');
},
actions: {
update: function () {
this.set('bar', 'updated');
console.log(this.get('foo'));
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
Model: {{model}}
<br>
<br>
<a {{action 'update'}}>Update</a>
{
"version": "0.9.0",
"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.6.0",
"ember-data": "2.6.0",
"ember-template-compiler": "2.6.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment