Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember.js: difference between {{#collection}} and {{#each}}?

In Ember.js, what's the difference between using {{#collection}} and {{#each}}? In which cases would you use which?

like image 475
nicholaides Avatar asked Sep 27 '26 21:09

nicholaides


1 Answers

Hum, well... quite a good question... as you can see here : #729, it seems that the {{collection}} helper is going to be deprecated in favor of using always {{#each}}. But at this time, all features available in {{#collection}} are not in {{#each}}.

So, I would recommend you to use {{#each}} when it works for you, and only use {{collection}} when absolutely needed. (when you need to define itemViewClass for example).

Update: since 1.0.0-pre.2, the itemViewClass attribute to the each helper. The only remaining thing the collection helper has over the each one, is you can explicitely define the collection class to use if you have extended Ember.CollectionView.

like image 110
sly7_7 Avatar answered Sep 29 '26 11:09

sly7_7