0

In my controller, I have data like this:

"type":       [
              {
        "aMap": {"5.0": 0},
        "bMap": {"10.0": 0},
        "cMap": {"15.0": 0},
        "dMap": {"20.0": 0},
        "desc": "CG"
},
{
        "aMap": {"5.0": 0},
        "bMap": {"10.0": 0},
        "cMap": {"15.0": 0},
        "dMap": {"20.0": 0},
        "desc": "CG"
}]

It contains arrays which has multiple maps. I want to read both key, value in the maps in my html using ng-repeat. How can I do this?

Tanuj
  • 71
  • 2
  • 13
  • 1
    possible duplicate of http://stackoverflow.com/questions/14704147/how-to-use-ng-repeat-to-iterate-over-map-entries-in-angularjs – Naghaveer R Feb 06 '17 at 09:36
  • Possible duplicate of [How to use ng-repeat to iterate over map entries in AngularJS](http://stackoverflow.com/questions/14704147/how-to-use-ng-repeat-to-iterate-over-map-entries-in-angularjs) – frhd Feb 06 '17 at 09:45

2 Answers2

0

You can use ng-repeat like this:

<div ng-repeat="foo in data">
  <div ng-repeat="(key, val) in foo">
rrd
  • 5,789
  • 3
  • 28
  • 36
0

In your view you can loop using:

<div ng-repeat="item in type">
    <div ng-repeat="(key, val) in item">
      <b>KEY</b> : {{key}}
      <b>ITEM</b> : {{val}}
      <br/>
      <i>KEY / VAL of data :</i>
      <div ng-repeat="(keylower, vallower) in val">
        {{keylower}} - {{vallower}}
      </div>
      <br/><br/>
    </div>
</div>

See this code example on Plunkr : https://plnkr.co/edit/nXEwJ5IcD4Cu8wrFjR2R?p=preview

daan.desmedt
  • 3,752
  • 1
  • 19
  • 33