In Ember.js, what’s the difference between using {{#collection}} and {{#each}}? In which cases would you use which?
In Ember.js, what’s the difference between using {{#collection}} and {{#each}} ? In which cases
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
collectionhelper has over theeachone, is you can explicitely define the collection class to use if you have extended Ember.CollectionView.