Skip to content

Instantly share code, notes, and snippets.

@k-fish
Created July 18, 2016 20:12
Show Gist options
  • Save k-fish/c8157a5acd077a260aaf4268b4e354a5 to your computer and use it in GitHub Desktop.
Save k-fish/c8157a5acd077a260aaf4268b4e354a5 to your computer and use it in GitHub Desktop.
Computed input
import Ember from 'ember';
export default Ember.TextField.extend({
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
formatValue(value) {
return parseFloat(value).toFixed(2);
},
foobar: '123',
computedFoobar: Ember.computed({
get() {
return this.formatValue(this.get('foobar'));
},
set(key, value) {
return this.formatValue(this.set('foobar', value));
}
}),
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{my-component value=computedFoobar}}
{{foobar}}
{{computedFoobar}}
<br>
<br>
{
"version": "0.10.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.6.0",
"ember-data": "2.6.1",
"ember-template-compiler": "2.6.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment