Skip to content

Instantly share code, notes, and snippets.

@dbouwman
Forked from Serabe/components.my-component.js
Last active March 21, 2017 18:19
Show Gist options
  • Save dbouwman/8b1481c1cf5fd61a4ba76e71497e1f6e to your computer and use it in GitHub Desktop.
Save dbouwman/8b1481c1cf5fd61a4ba76e71497e1f6e to your computer and use it in GitHub Desktop.
Normal Checkbox
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
toggleValue() {
this.toggleProperty('value');
},
inputChanged(value) {
if (typeof this.onchange === 'function') {
this.onchange(value);
}
console.log(value);
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
val:true,
});
import Ember from 'ember';
export function not([val]/*, hash*/) {
return !val;
}
export default Ember.Helper.helper(not);
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{my-component value=val
change=(action (mut val) (not val))}}
<br>
<br>
<label {{action "toggleValue"}}>
<input type="checkbox" checked={{value}} onchange={{action "inputChanged" value="target.value"}}> CLICKABLE LABEL (checked: {{value}})
</label>
Value Is: {{value}}
{
"version": "0.10.6",
"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.9.0",
"ember-data": "2.9.0",
"ember-template-compiler": "2.9.0",
"ember-testing": "2.9.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment