4

Possible Duplicate:
AngularJS - How can I reference the property name within an ng-Repeat

I have a JSON file like that:

fields: {
    alias: {
        type: "string",
    },
    name: {
        type: "string",
    }
}

I want something like that:

<dl ng-repeat="for field in fields.items">
    <dt>
        {{ field.key }}
    </dt>
    <dd>
        {{ field.value }}
    </dd>
</dl>

thanks in advance!

Community
  • 1
  • 1
zVictor
  • 3,610
  • 3
  • 41
  • 56
  • found an answer: http://stackoverflow.com/questions/10954286/angularjs-how-can-i-reference-the-property-name-within-an-ng-repeat – zVictor Jun 11 '12 at 21:13

1 Answers1

14

according to ngRepeat docs you can use "(key, value) in expression" as parameters – where key and value can be any user defined identifiers, and expression is the scope expression giving the collection to enumerate.

For example: (name, age) in {'adam':10, 'amalie':12}.

http://docs.angularjs.org/api/ng.directive:ngRepeat

zVictor
  • 3,610
  • 3
  • 41
  • 56
  • 3
    Sweet! Thank you. It's probably silly but simple answers here actually are helping me a lot with learning to read and implement the AngularJS docs. – noogrub Jul 01 '12 at 09:58