jeudi 27 août 2015

Looping Through Ember-Data Model Attrs in a Template

I'm trying to figure out how to dynamically loop through the attributes of an Ember-Data Model I've passed into a Component. Here's what I have:

Templates:

{{!person.hbs}}
{{each-in person as |property value|}}
  <tr>
    <th>
      <td>{{property}}</td>
      <td>{{value}}</td>
    </th>
  </tr>
{{/each-in}}

{{!index.hbs}}
{{person-component person=model}}

Model:

import DS from 'ember-data';

export default DS.Model.extend({
  "name": DS.attr('string'),
  "height": DS.attr('number'),
  "weight": DS.attr('number'),
});

Route:

import Ember from 'ember';

export default Ember.Route.extend({
  model() {
    return this.store.find('secret');
  }
});

Is there a simple way to do this from within handlebars? I was thinking possibly that a computed value on the controller might have to do it.




Aucun commentaire:

Enregistrer un commentaire