A helper sentencesList
is an array of objects containing an element text
.
HTML:
{{#each sentencesList}}
{{text}}
{{/each}}
CLIENT.JS
sentencesList: function() {
return Session.get(SENTENCES)
}
How can I reverse the ordering, i.e the highest index number is shows at the top and the element at index position 0 is at the bottom?
You could just reverse
the array:
sentencesList: function() {
return Session.get(SENTENCES).reverse();
}
Please note: although {{#each}}
works on both arrays and cursors, this method is array-specific. So you cannot use it, say, on the return of a Collection.find()
call. To achieve this with a collection, you will have to use sort
on the key you want to reverse order from.