Skip to content

Instantly share code, notes, and snippets.

@courthead
Created December 23, 2015 20:58
Show Gist options
  • Save courthead/da00e9fcb5b7a918916b to your computer and use it in GitHub Desktop.
Save courthead/da00e9fcb5b7a918916b to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
prop: 'a',
actions: {
setPropToA() {
this.set('prop', 'a');
this.notifyPropertyChange('prop');
},
setPropToZ() {
this.set('prop', 'z');
this.notifyPropertyChange('prop');
}
}
});
{{my-component prop=(readonly prop)}}
<br>
<br>
<button onclick={{action "setPropToA"}}>Set attrs.prop to A</button>
<br>
<button onclick={{action "setPropToZ"}}>Set attrs.prop to Z</button>
import Ember from 'ember';
export default Ember.Component.extend({
prop: 'b',
actions: {
setPropToC() {
this.set('prop', 'c');
}
}
});
<p>prop: {{prop}}</p>
<p>attrs.prop: {{attrs.prop}}</p>
<button onclick={{action "setPropToC"}}>Set prop to "c"</button>
{
"version": "0.4.17",
"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.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment