Skip to content

Instantly share code, notes, and snippets.

@scottkidder
Created October 29, 2015 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottkidder/fee4b39d5acc7503de11 to your computer and use it in GitHub Desktop.
Save scottkidder/fee4b39d5acc7503de11 to your computer and use it in GitHub Desktop.
Computed not firing on hash
import Ember from 'ember';
export default Ember.Controller.extend({
hash: {
firstItem: 'abc',
},
getFirstItem: Ember.computed('hash', function() {
return this.get('hash.firstItem');
}),
actions: {
changeHash() {
this.set('hash', {firstItem: 'xyz'});
}
}
});
First item is: {{getFirstItem}} (computed)<br />
First item is: {{hash.firstItem}} (actual)
<br />
Update: {{input value=hash.firstItem}}
<button {{action 'changeHash'}} type='button'>ChangeHash</button>
{
"version": "0.4.14",
"EmberENV": {
"FEATURES": {}
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.1.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment