Skip to content

Instantly share code, notes, and snippets.

@Sinled
Created January 27, 2017 12:58
Show Gist options
  • Save Sinled/8beff8a0abb1a1639a166f22060c4934 to your computer and use it in GitHub Desktop.
Save Sinled/8beff8a0abb1a1639a166f22060c4934 to your computer and use it in GitHub Desktop.
check-ember-composable-helpers
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
someCollection: [
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
{ id: 5 },
],
actions: {
isEven(id) {
return id % 2 == 1;
},
addElements() {
alert('add more')
this.set('someCollection', [
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
{ id: 5 },
{ id: 6 },
{ id: 7 },
{ id: 8 },
]);
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
some collection
<br>
<h1>collection filtered</h1>
<ul>
{{#each (filter-by 'id' (action 'isEven') someCollection) as |item| }}
<li>{{item.id}}</li>
{{/each}}
</ul>
<br>
<button type='button' onclick={{action 'addElements'}}>add more</button>
<br>
{{#each someCollection as |item| }}
<li>{{item.id}}</li>
{{/each}}
{
"version": "0.11.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.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {
"ember-composable-helpers": "1.1.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment