vishalaksh vishalaksh - 3 months ago 16
AngularJS Question

How to use ng-repeat for nested dictionaries in AngularJs?

I have a dictionary where the value is itself an object. I want to show the entries in a table using

ng-repeat
.

Here is the dictionary:

{
'adam': {
c1: "a",
c2: "b"
},
'amalie': {
c1: "c",
c2: "d"
}
};


I have visited this question but it talks about simple key-value pairs.

Here is a jsfiddle.

I want it to be shown as:

NAME c1 c2
adam a b
amalie c d

Answer
<ul>
    <li ng-repeat="(name, ages) in items">              
        {{name}} 
        <span ng-repeat="age in ages">
            {{age}}
        </span>        
    </li>
</ul>

jsfiddle

Comments