-1

I have the following data structure:

{
"0": {
"keyword": "lawn",
"short_desc": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"pt_value": "10"
},
"1": {
"keyword": "lawn",
"short_desc": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"pt_value": "10"
},
"2": {
"keyword": "lawn",
"short_desc": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"pt_value": "10"
},
"3": {
"keyword": "lawn",
"short_desc": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"pt_value": "10"
},
"4": {
"keyword": "lawn",
"short_desc": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"pt_value": "10"
},
"5": {
"keyword": "lawn",
"short_desc": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"pt_value": "10"
}
}

I need to run ng-repeat like this:

<div ng-controller="myController">
    <div ng-repeat="SOMETHING">
        <p>{{ desc }}</p>
        <p>{{ points }}</p>
    </div>
</div>

Obviously I can run something as simple as ng-repeat="product as products" so how can I iterate through the data, repeat, and place content where I need it?

PSL
  • 123,204
  • 21
  • 253
  • 243
dcp3450
  • 10,959
  • 23
  • 58
  • 110

1 Answers1

0

You may want to take a look at the syntax of ng-repeat expressions, you could still manage the repeat with an object.

Provided scope.items represent the object in the question:

<div ng-controller="myController">
    <div ng-repeat="(k, item) in items">
        <p>{{ item.short_desc}}</p>
        <p>{{ item.pt_value}}</p>
    </div>
</div>

(key, value) in expression – where key and value can be any user defined identifiers, and expression is the scope expression giving the collection to enumerate.

PSL
  • 123,204
  • 21
  • 253
  • 243