Skip to content

Instantly share code, notes, and snippets.

@HenryVonfire
Created December 8, 2015 13:51
Show Gist options
  • Save HenryVonfire/87d0690e756ca77bce4c to your computer and use it in GitHub Desktop.
Save HenryVonfire/87d0690e756ca77bce4c to your computer and use it in GitHub Desktop.
SO example
import Ember from 'ember';
export default Ember.Controller.extend({
isFullView:false,
model:[{name:'a'},{name:'b'},{name:'c'},{name:'d'}],
actions:{
seeMore(){
this.set('isFullView', true);
}
}
});
{{#if isFullView}}
{{#each model as |item|}}
{{item.name}} <br>
{{/each}}
{{else}}
{{#each model as |item index|}}
{{#if (check-index index 2)}}
{{item.name}}<br>
{{/if}}
{{/each}}
<button {{action 'seeMore'}}>See more...</button>
{{/if}}
import Ember from 'ember';
export function checkIndex(params/*, hash*/) {
const leftValue = params[0];
const rightValue = params[1];
return leftValue < rightValue;
}
export default Ember.Helper.helper(checkIndex);
{
"version": "0.4.17",
"EmberENV": {
"FEATURES": {}
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment