Skip to content

Instantly share code, notes, and snippets.

@k-fish
Created June 23, 2016 18:14
Show Gist options
  • Save k-fish/0eb09d2147d7c488d3eca24b92102ab7 to your computer and use it in GitHub Desktop.
Save k-fish/0eb09d2147d7c488d3eca24b92102ab7 to your computer and use it in GitHub Desktop.
Double bound fields 2
import Ember from 'ember';
export default Ember.Component.extend({
total: 1000,
actions: {
changedPercentage: function(value) {
this.set('amount', value * this.get('total'));
},
changedAmount: function(value) {
this.set('percentage', value / this.get('total'));
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{my-component}}
<br>
<br>
{{yield}}
{{input onkeyup=(action 'changedPercentage') value=amount placeholder="percentage"}}
{{input onkeyup=(action 'changedAmount') value=percentage placeholder="amount"}}
{
"version": "0.9.3",
"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.6.0",
"ember-data": "2.6.1",
"ember-template-compiler": "2.6.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment