I have a model like this
var model = Model.extend({
id: attr(),
profileName: attr(),
email: attr(),
role: attr(),
...
});
And now I need to attach to it some metadata/static attribute.
var model = Model.extend({
id: attr(),
profileName: attr(),
email: attr(),
role: attr(),
...
viewOrder: Ember.computed(function() {
return [get(this, 'id'), get(this, 'email'), get(this, 'role'), get(this, 'profileName'), ...];
}),
viewColNames: Ember.computed(function() {
return ['Id', 'Email', 'Role', 'Username', ...];
})
});
And then in the view I've got something like this:
<tbody>
<tr>
<td></td>
</tr>
</tbody>
Which is not great, but it works, but i would also like to do something like that:
<thead>
<tr>
<th></th>
</tr>
</thead>
(I am aware this does not work)
So my question is how can i read static attribute of model in template or even better, set metadata (viewOrder, viewColNames) to model and then read it in template, or if there is any other better way to handle this situation.
Thanks
Aucun commentaire:
Enregistrer un commentaire