Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chadhietala/6c0b3a6424186394b433290afcc0ea18 to your computer and use it in GitHub Desktop.
Save chadhietala/6c0b3a6424186394b433290afcc0ea18 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
attributeBindings: ['style'],
expanded: false,
init() {
this._super(...arguments);
this.incrementProperty('count');
},
style: Em.computed('expanded', function() {
if(this.get('expanded')) {
return `background-color: lightgreen`.htmlSafe();
} else {
return `background-color: yellow`.htmlSafe();
}
}),
count: 0,
actions: {
toggle() {
this.incrementProperty('count');
this.toggleProperty('expanded');
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
});
<h1>Ember Alpha</h1>
{{my-component}}
<h1>The count is {{count}}</h1>
<button {{action 'toggle'}}>Toggle</button>
{{#if expanded}}
<ol>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
</ol>
{{/if}}
{
"version": "0.10.4",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "alpha",
"ember-data": "2.7.0",
"ember-template-compiler": "alpha"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment