Skip to content

Instantly share code, notes, and snippets.

@aaronfischer
Last active August 25, 2016 16:36
Show Gist options
  • Save aaronfischer/9b9bdcc9fc2128481a7dc830fa1bbd69 to your computer and use it in GitHub Desktop.
Save aaronfischer/9b9bdcc9fc2128481a7dc830fa1bbd69 to your computer and use it in GitHub Desktop.
Recursive Reverse List
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'ul',
display: Ember.computed('data', function() {
return this.get('data').pop();
}),
nested: Ember.computed('data', function() {
return this.get('data').slice(0, -1);
}),
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
reversedList: [{id: 21}, {id: 16}, {id: 1}],
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{app-activity-tree data=reversedList}}
<br>
<br>
<li>
{{display.id}}
{{#if nested}}
{{app-activity-tree data=nested}}
{{/if}}
</li>
{
"version": "0.10.4",
"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.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment