1
votes

How does bind values of embedded JSON data to input elements in EmberJS as I cannot seem to find a straight forward way to get that done.

update

It doesn't seem to work for a JSON object with this structure

{
  "users": [
    {
     "_id": "534550428047526419000002",
      "Name": "admin",
      "Code": "admin",
      "Age": 12,
      "Sex": "Male",
      "Ethnicity": "admin",
      "EventTime": "",
      "Accident": [
        {
          "value": true,
          "risk": "Medium"
        }
      ]
    }
 ]
}
1

1 Answers

0
votes

In the template you use the property name

{{foo}}

{{input value=foo}}

Example

http://emberjs.jsbin.com/wufegaca/1/edit

nested properties are handled the same way they are in most languages with the dot operator

{{foo.bar}}

{{input value=foo.bar}}

Example

http://emberjs.jsbin.com/wufegaca/2/edit

Using an array you need to iterate over the array. If you didn't how would Ember know which item you were referring to? Additionally upper case property names are problematic in handlebars, since it usually denotes a global namespace, so be wary if things don't appear to be working.

Example

http://emberjs.jsbin.com/wufegaca/3/edit