Skip to content

Instantly share code, notes, and snippets.

@davidpett
Last active June 6, 2016 15:08
Show Gist options
  • Save davidpett/db2fd8fa47c2862160af75aa77f242f7 to your computer and use it in GitHub Desktop.
Save davidpett/db2fd8fa47c2862160af75aa77f242f7 to your computer and use it in GitHub Desktop.
style
import Ember from 'ember';
const {
computed,
get
} = Ember;
export default Ember.Component.extend({
attributeBindings: ['style'],
style: computed('isFoo', function() {
let style = get(this, 'isFoo') ? 'color: red' : 'color: blue';
return style.htmlSafe();
}),
isFoo: false,
click() {
this.toggleProperty('isFoo');
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#my-component}}
hello
{{/my-component}}
{{outlet}}
<br>
<br>
{
"version": "0.8.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.5.1",
"ember-data": "2.5.2",
"ember-template-compiler": "2.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment