Skip to content

Instantly share code, notes, and snippets.

@vasilionjea
Created December 13, 2017 20:01
Show Gist options
  • Save vasilionjea/29ca2230392ec5ae295034c1e5a9c842 to your computer and use it in GitHub Desktop.
Save vasilionjea/29ca2230392ec5ae295034c1e5a9c842 to your computer and use it in GitHub Desktop.
Ember `mut` helper
import Ember from 'ember';
export default Ember.Component.extend({
input(e) {
// The `mut` helper changes the `appName` value to what
// is provided as the `action` argument.
this.get('onNewValue')(e.target.value);
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
});
<h1>Welcome to {{appName}}</h1>
{{outlet}}
{{!--
The `mut` helper changes the `appName` value to
what is provided as the `action` argument.
--}}
{{my-component
onNewValue=(action (mut appName))
}}
<input type="text" placeholder='Enter your app name...'>
{
"version": "0.12.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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment