Iterating over a model's attributes in EmberJS handlebars template

前端 未结 2 1532
日久生厌
日久生厌 2020-12-06 14:56

Is there a way to iterate over a view\'s context\'s attributes in EmberJS? I am using Ember-Data (https://github.com/emberjs/data) for ORM.

Lets say I use connectOut

2条回答
  •  攒了一身酷
    2020-12-06 15:18

    The Ember Data objects that represent your models have an attributes property that contains all of the attributes for the given model. This is what Ember Data's toJSON uses to convert your models into Javascript objects.

    You can use this attributes property to read a models attributes and then pull those specific attributes out of an instance. Here is an example.

    http://jsfiddle.net/BdUyU/1/

    Just to reiterate what's going on here. We are reading the attributes from App.User and then pulling the values out of App.ryan and App.steve. Hope this makes sense.

提交回复
热议问题