Skip to content

Instantly share code, notes, and snippets.

@mattmazzola
Created October 21, 2015 06:27
Show Gist options
  • Save mattmazzola/8850872b6f3f1e2bf737 to your computer and use it in GitHub Desktop.
Save mattmazzola/8850872b6f3f1e2bf737 to your computer and use it in GitHub Desktop.
Selection Add Class
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
selectedItem: null,
things: [
{ name: 'a' },
{ name: 'b' },
{ name: 'c' }
],
actions: {
selectItem(thing) {
this.set('selectedItem', thing);
}
}
});
<h1>Welcome to {{appName}}</h1>
<ul>
{{#each things as |thing| }}
<li><button {{action "selectItem" thing}} type="button">{{thing.name}}</button></li>
{{/each}}
</ul>
<br>
Selected Item: {{selectedItem.name}}
<br>
{{outlet}}
<br>
<br>
{
"version": "0.4.13",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.10/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.13/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.10/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment