Last active
October 16, 2015 15:04
-
-
Save amk221/3e2364e989a706f5d222 to your computer and use it in GitHub Desktop.
x-each
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
console.log('Entered application route'); | |
let items = []; | |
for (let i = 0; i < 100; i++) { | |
items.push({name: "Item " + i}); | |
} | |
return items; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
li { | |
border: 1px solid red; | |
min-height: 50px | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.4.13", | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.10/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.13/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.10/ember-template-compiler.js" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
let XEachComponent = Ember.Component.extend({ | |
tagName: '', | |
didReceiveAttrs() { | |
let items = this.get('items') || []; | |
let amount = this.getAttr('amount') || 10; | |
this.set('xItems', items.slice(0, amount)); | |
Ember.run.next(this, 'set', 'xItems', items); | |
} | |
}); | |
XEachComponent.reopenClass({ | |
positionalParams: ['items'] | |
}); | |
export default XEachComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment