Skip to content

Instantly share code, notes, and snippets.

@zackthehuman
Created October 31, 2016 18:55
Show Gist options
  • Save zackthehuman/8b3d5b461c7d6bd5979bdfc3018ab9b1 to your computer and use it in GitHub Desktop.
Save zackthehuman/8b3d5b461c7d6bd5979bdfc3018ab9b1 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
locales: Ember.ArrayProxy.create({ content: Ember.A(['de_DE', 'fr_FR']) }),
someValue: '',
actions: {
addNew() {
console.log('add new');
const locales = this.get('locales');
const value = this.get('someValue'); locales.addObject(value);
this.set('someValue', '');
}
}
});
import Ember from 'ember';
export function eq(params/*, hash*/) {
return params[0] === params[1];
}
export default Ember.Helper.helper(eq);
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<button type="button" {{action 'addNew'}}>Add new</button>
<ul>
{{#each locales as |locale index|}}
<li>{{locale}}</li>
{{#if (eq index (get locales 'length'))}}
<li>the end!!</li>
{{/if}}
{{/each}}
<li>{{input type="text" class="foobar" value=someValue enter=(action 'addNew')}}</li>
</ul>
{
"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