Skip to content

Instantly share code, notes, and snippets.

@SaladFork
Created April 21, 2016 14:35
Show Gist options
  • Save SaladFork/5dc15ac7454fc3c669d2af194f9b13e1 to your computer and use it in GitHub Desktop.
Save SaladFork/5dc15ac7454fc3c669d2af194f9b13e1 to your computer and use it in GitHub Desktop.
No Setter Behaviors
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
a: Ember.computed(function() {
return 0;
}),
b: Ember.computed({
get() {
return 0;
}
}),
c: Ember.computed(function() {
return 0;
}).readOnly(),
d: Ember.computed({
get() {
return 0;
}
}).readOnly(),
actions: {
increment(prop) {
this.incrementProperty(prop);
}
}
});
<button {{action 'increment' 'a'}}>
Increment A (function): {{a}}
</button>
<button {{action 'increment' 'b'}}>
Increment B (get()): {{b}}
</button>
<button {{action 'increment' 'c'}}>
Increment C (function+readOnly): {{c}}
</button>
<button {{action 'increment' 'd'}}>
Increment D (get()+readOnly): {{d}}
</button>
{
"version": "0.7.2",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.4/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.3/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.4/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment