Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKevin Lozandier
Courses Plus Student 53,747 PointsFYI: The {{#each}} loop during the demonstration of looping over an array/model in Ember Apps is deprecated...
Just a Head's up to people who decide to start this course this month with the latest version(s) of Ember since this course was released involving plain old javascript objects (POJOs):
The plain {{#each}} loop is now deprecated, the following should be done instead:
{{#each post in model}}
<!-- The intent of your loop, like post.title, post.author_name, and etc...
{{\each}}
Also, there seems to be a minor tweak to how models are hooked from the route to the controller; being familiar with Ember in the past, I'll update this thread if the changes aren't intuitive .
Edit: Used posts
instead of model
by mistake
Benjamin Dalton
10,725 PointsThanks! It's not as simple as the deprecated each but I suppose it's possible it's needed for some very necessary reason or they wouldn't have changed it. Maybe some each's were getting their streams crossed?
4 Answers
Michael Kaiser-Nyman
Treehouse Guest TeacherKevin Lozandier thanks for all your help on the forums with Ember! This deprecation is because of the confusion that can be caused by the context switching the block helper does. The Ember folks decided we should be more explicit. They also are changing the preferred syntax to {{#each model as |post|}}
, which is even more readable and clear.
Eric Follows
25,399 PointsThat's great man, thanks...but how did you get the recent-comments.hbs to work? I tried the same format, but it doesn't seem to work for me.
<ul>
{{#each model as |post|}}
<li>{{comments.text}}</li>
{{/each}}
</ul>
When I check it out in the browser, all I see are the bullets without any text...
Michael Kaiser-Nyman
Treehouse Guest TeacherYou'd need to do:
<ul>
{{#each model as |comment|}}
<li>{{comment.text}}</li>
{{/each}}
</ul>
The name between the pipes (|comment|
) has to match the name you use in the expression (comment.text
).
Eric Follows
25,399 PointsNice, that did it. I see my mistake now, thanks!
Kevin Lozandier
Courses Plus Student 53,747 PointsKevin Lozandier
Courses Plus Student 53,747 PointsMaybe Michael Kaiser-Nyman can comment what may also deprecate the instructions about loading POJOs through Arrays (though in practice I and most would use Fixtures at worst)....
index.haml
templates/posts.hbs
routes/posts.js
router.js
store.js