Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I list by keys and values in angularjs? [duplicate]

Tags:

angularjs

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!

like image 908
zVictor Avatar asked Dec 09 '22 23:12

zVictor


1 Answers

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

like image 156
zVictor Avatar answered Jan 18 '23 20:01

zVictor