Skip to content

Instantly share code, notes, and snippets.

@piotrpalek
Last active June 9, 2016 15:06
Show Gist options
  • Save piotrpalek/b65780093f41d52d56a7 to your computer and use it in GitHub Desktop.
Save piotrpalek/b65780093f41d52d56a7 to your computer and use it in GitHub Desktop.
setter till 1.12
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
actions: {
updateAttr() {
this.set('otherattr', Math.random());
}
}
});
<h1>1.12 setter</h1>
<br>
<br>
{{some-comp ottherattr=otherattr setterattr=setterattr}}
<button {{action "updateAttr"}}>update otherattr</button>
<br>
<br>
import Ember from 'ember';
export default Ember.Component.extend({
otherattr: null,
setterattr: Ember.computed({
get() {
return 'anything';
},
set(key, value) {
this.set('datestamp', Date.now());
}
})
});
Datestamp (updated in setterattr): {{datestamp}}
<br />
<br />
{
"version": "0.4.16",
"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/1.12.1/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/1.12.1/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment