Skip to content

Instantly share code, notes, and snippets.

@tzellman
Last active May 4, 2017 11:45
Show Gist options
  • Save tzellman/576b36d6ea651994e7a529e17970a6ac to your computer and use it in GitHub Desktop.
Save tzellman/576b36d6ea651994e7a529e17970a6ac to your computer and use it in GitHub Desktop.
composable test
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init(){
this.setProperties({
ids: [1, 3, 5],
objects: [{id:1, label:'one'}, {id:2, label:'two'}, {id:3, label:'three'}, {id:4, label:'four'}, {id:5, label:'five'}]
});
},
actions:{
isIn(arr, val){
console.log(val);
return arr.includes(val);
}
}
});
import Ember from 'ember';
export function includes([arr, obj]/*, hash*/) {
console.log(obj);
return arr.includes(obj);
}
export default Ember.Helper.helper(includes);
<ol>
{{#each (filter-by "id" (r 'includes' ids) objects) as |object|}}
<li>{{object.label}}</li>
{{/each}}
</ol>
{
"version": "0.12.1",
"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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1",
"ember-composable-helpers": "2.0.1",
"ember-reactive-helpers": "0.4.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment