Skip to content

Instantly share code, notes, and snippets.

@mastastealth
Created March 29, 2018 13:45
Show Gist options
  • Save mastastealth/07d8aef6ae67e2d0b7d4f8194616fbca to your computer and use it in GitHub Desktop.
Save mastastealth/07d8aef6ae67e2d0b7d4f8194616fbca to your computer and use it in GitHub Desktop.
Nested Array Template
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
list: [
{ name: "Apple", colors: ["Red","Yellow","Green"] },
{ name: "Orange", colors: ["Orange"] },
{ name: "Grape", colors: ["Green", "Purple"] }
],
newGrape() {
this.list[2].colors.pushObject('Red');
}
});
<h1>Welcome to {{appName}}</h1>
<div>
{{#each list as |x|}}
<div>{{x.name}} | {{x.colors.length}}</div>
{{/each}}
</div>
<br>
<button {{action newGrape}}>
Discover New Grape Color
</button>
{
"version": "0.13.0",
"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.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment