Reputation: 4310
I have a JSON object (tbls
) which contains an array called sections
. This array contains titles (n
) and IDs (viewid
) of "rooms" that are also a part of the JSON object. This means you can do tbls.[roomid]
and get the array that contains the objects of each room. I have a hard time making this work in Angular.
It was built this way because it makes it easy to work with when it comes to UITableViews in iOS (where it's implemented and works). Therefore I cannot change the data. I tried below solution, but that gives me an error. Is there an effective way to do this in Angular?
<tbody data-ng-repeat="section in tbls.sections">
<tr>
<td>{{::section.n}}</td>
</tr>
<tr data-ng-repeat="table in tbls.{{section.viewid}}">
<td>{{::table.n}}</td>
</tr>
</tbody>
JSON JSFiddle: https://jsfiddle.net/Lu2ocqku/ Edit: removed tableObj as it's not relevant to the question and doesn't match data example exactly. Same logical problem though.
Edit: Since I asked this question I have changed it to be properly nested with an array of sections containing what is in that section as well. Don't do what I did in this question, originally.
Upvotes: 1
Views: 267
Reputation: 171669
You just need to use standard []
javascript object syntax:
<tr data-ng-repeat="table in tbls[section.viewid]">
Upvotes: 1