Skip to content

Instantly share code, notes, and snippets.

@gtb104
Last active January 21, 2016 16:07
Show Gist options
  • Save gtb104/2f0a163e02e13b67d3b9 to your computer and use it in GitHub Desktop.
Save gtb104/2f0a163e02e13b67d3b9 to your computer and use it in GitHub Desktop.
myTwiddle
import Ember from 'ember';
export default Ember.Controller.extend({
a: [1,2,3],
b: [4,5,6],
c: false,
actions: {
toggleLabels() {
this.toggleProperty('c');
}
}
});
<h1>Parent</h1>
<div {{action 'toggleLabels'}}>
<span class="button">Toggle Labels</span>
</div>
<br>
<br>
{{my-comp a=a b=b c=c}}
<br>
<br>
import Ember from 'ember';
export default Ember.Component.extend({
a: null,
b: null,
_b: null,
__b: Ember.computed('b', {
get() {
return this.get('__b');
},
set(key, value) {
console.log('processing "b"');
this.set('__b', value);
return value;
}
}),
didUpdateAttrs(attrs) {
console.log(attrs.newAttrs, attrs.oldAttrs)
},
didInsertElement() {
console.log(this.__b);
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.button {
border-radius: 2px;
border: 1px solid black;
background-color: grey;
color: white;
cursor: pointer;
padding: 4px;
}
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"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.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