I am being passed a JSON object via an API service. I have NO CONTROL over the format of the JSON. It is however a valid JSON object:
{
"Template" : {
"Parameters" : {
"Name" : "Test",
"Version" : "1.0"
},
"Fields" : {
"Field" : [{
"Prompt" : "Last Name:"
}, {
"Prompt" : "First Name:"
}, {
"Prompt" : "Middle Name"
}, {
"Prompt" : "ID Number:"
}
]
},
"Captures" : {
"Capture" : [{
"Prompt" : "Picture"
}, {
"Prompt" : "Picture from file"
}, {
"Prompt" : "Signature"
}
]
}
}
}
What I need to do is loop through a list of the Fields in the object, so that I can display values from there. In the case of this example, I am trying to print a list of Prompt values from the Fields.
http://jsfiddle.net/toddhd/0wbfpxkj/9/
<div ng-repeat="item in template.Fields.Field">
{{item.Prompt}}
</div>
This is explained MUCH better by looking at the JSFiddle above.
What I WANT to do is simply get the list of fields using dot/point notation, such as:
template.Fields.Field
But that isn't working for me. In the example, I also made a series of ng-repeats which loop through each collection one by one. That works and produces the desired result, but it's verbose and ugly.
I'm sure I'm just misunderstanding the structure of the JSON object itself, or maybe the correct dot/point notation to get there. But I just can't seem to figure it out. Can you please take a look and tell me where I'm going wrong?
Thank you
ng-repeat="(k, v) in obj"- a fiddle with the correct repeat syntax: jsfiddle.net/0wbfpxkj/11