javascript - How can I reverse the ordering of spacebars #each block -
a helper sentenceslist array of objects containing element text.
html:
{{#each sentenceslist}} {{text}} {{/each}} client.js
sentenceslist: function() { return session.get(sentences) } how can reverse ordering, i.e highest index number shows @ top , element @ index position 0 @ bottom?
you reverse array:
sentenceslist: function() { return session.get(sentences).reverse(); } please note: although {{#each}} works on both arrays , cursors, method array-specific. cannot use it, say, on return of collection.find() call. achieve collection, have use sort on key want reverse order from.
Comments
Post a Comment