Skip to content

Instantly share code, notes, and snippets.

@inez
Last active November 14, 2018 01:00
Show Gist options
  • Save inez/3fb0ef571ea835c6265d45dd63473ffe to your computer and use it in GitHub Desktop.
Save inez/3fb0ef571ea835c6265d45dd63473ffe to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
lineItems: [],
init() {
this._super(...arguments);
this.lineItems.push(11);
this.lineItems.push(22);
this.lineItems.push(33);
},
actions: {
input: function(index,e) {
console.log(e.target.value);
this.set('lineItems[' + index + ']', e.target.value);
this.set('lineItems', Ember.copy(this.lineItems));
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<ul>
{{#each lineItems as |lineItem index|}}
<li>{{lineItem}} {{input value=lineItem input=(action 'input' index)}}</li>
{{/each}}
</ul>
<br>
<br>
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment