Skip to content

Instantly share code, notes, and snippets.

@camskene
Created August 12, 2018 23:49
Show Gist options
  • Save camskene/4b3dc99abf4f63c1ca06997f8e545a8a to your computer and use it in GitHub Desktop.
Save camskene/4b3dc99abf4f63c1ca06997f8e545a8a to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
activeItem: undefined,
items: Ember.computed(function() {
return [
{
title: 'Item 1',
},
{
title: 'Item 2',
},
{
title: 'Item 3',
},
];
}),
actions: {
toggleActiveItem(item) {
this.set('activeItem', item);
},
},
});
<h1>The app</h1>
{{#each items as |item|}}
<h3 {{action 'toggleActiveItem' item}}>{{item.title}}</h3>
{{#if (eq item activeItem)}}
body
{{/if}}
{{/each}}
{
"version": "0.15.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": true,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.2.2",
"ember-template-compiler": "3.2.2",
"ember-testing": "3.2.2"
},
"addons": {
"ember-truth-helpers": "2.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment