javascript - Ember.js, Looping through two array's with {{each}} loops -
i'm using ember.js , i’m building dynamic table. user uploads tsv file , display data in table. format of these files not uniform, different every time, cannot hard code column names. right have array of column names , have array of objects data tsv file. possible ember use 2 {{each}} loops display data? issue in second loop cannot use dot notation or brackets second looping variable. there ‘ember way’ solution common problem?
<table class="table"> <thead> <tr> {{#each columns |name|}} <th>{{name}}</th> {{/each}} </tr> </thead> <tbody> {{#each filedata |data|}} <tr> {{#each columns |name|}} <td>{{data.name}}</td> <!-- doesn't work --> <td>{{data[name]}}</td> <!-- doesn't work --> {{/each}} </tr> {{/each}} </tbody> </table>
you're trying access properties of ember object using dynamic list. you're looking get helper.
in case:
{{#each filedata |data|}} {{#each columns |name|}} <td>{{get data name}}</td> {{/each}} {{/each}}
Comments
Post a Comment