lundi 2 février 2015

How to loop through sorted array controller in Ember.js?

Could you tell me the "best" way to loop through items with an ArrayController in Ember 1.9.1?


Let's take an ordered list of users as our example.


Previously I would have done this:



<ol>
{{#each itemController='user'}}
<li>{{name}}</li>
{{/each}}
</ol>


In version 1.9+ I understand this style has been deprecated.


Question one, am I correct to loop over the model? Like this:



<ol>
{{#each user in model itemController='user'}}
<li>{{user.name}}</li>
{{/each}}
</ol>


Question two, what if I want to use the controller sort functionality? Can I do this:



<ol>
{{#each user in arrangedContent itemController='user'}}
<li>{{user.name}}</li>
{{/each}}
</ol>


Question three, are there any other (more optimal) ways of looping over data with Ember?


Thanks!


Aucun commentaire:

Enregistrer un commentaire