ArrayController sorting with #each item in model

I am defining sort properties sortAscending and sortProperties in an ArrayController. When I render the model with {{#each}} the sorting works.

The problem (or the thing I’m not understanding) is when I use {{#each item in model}}. In this case the sorting gets overridden or just ignored. Is this normal behaviour and am I missing something out?

1 Like

Um … yes you are missing something. The sorting properties that you define in the controller are applied in the controller. Thus they are not applied when you access the model directly.

If your intention simply is to have an item variable, you can use {{#each item in controller}}.


Ok, thats great. Do you know any place where I can read up on this topic?

Hm … Controller guides show the general idea of accessing the model properties through controller properties instead of directly. I couldn’t easily find the fact that the controller itself is available as variable controller though. The ArrayController guide shows the sorting stuff (that shows that it’s a controller functionality).

I remember when I began with Ember you’d find examples with {{#each controller}} everywhere, but current guides have replaced them with {{#each}}. In the ArrayController API docs are still hints though.