Skip to content

Instantly share code, notes, and snippets.

@Serabe
Created November 26, 2016 23:35
Show Gist options
  • Save Serabe/2c083611aaaedfd978e1080104c03977 to your computer and use it in GitHub Desktop.
Save Serabe/2c083611aaaedfd978e1080104c03977 to your computer and use it in GitHub Desktop.
Normal Checkbox
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
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'
});
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>
<input type="checkbox" checked={{value}} onchange={{action "inputChanged" value="target.value"}}>
{{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