0

I try to access to nested JSON data into nested JSON data. I use ng-repeat, it works for the nested JSON data but not for the nested nested.

The data I want to catch is the server URL and their name.

<tr ng-repeat="site in dT.data.sites">
  <td>{{ site.siteName }}</td>
  <td><span ng-repeat="country in site.countries">{{ country.country + ' '}}<br><br></span></td>
  <!-- Does not work -->
  <td><span ng-repeat="country in site.countries">{{ country.masters.name }}</span></td>
  <!-- Works, but displays only the first element of the array because of the [0] -->
  <td><span ng-repeat="country in site.countries">{{ country.masters[0].name }}</span></td>
  <!-- Does not work -->
  <td><span ng-repeat="master in site.countries.masters">{{ master.name }}</span></td>
  <td></td>
  <td></td>
</tr>

PLUNKER

Maybe I have to use a function with a if…else method. Or use a service, but I would prefer to use ng-repeat.

0

2 Answers 2

1

You'll have to do an ng-repeat inside another ng-repeat. Something like this:

<td><span ng-repeat="country in site.countries"><span ng-repeat="master in country.masters">{{ master.name }}<br /></span></span></td>

I've made changes to your plunker to show this working: http://plnkr.co/edit/PdHesQRAeEMq38AgjxTm?p=preview

Sign up to request clarification or add additional context in comments.

Comments

1

Is this what you are looking for?

<td><span ng-repeat="country in site.countries[0].masters">{{ country.server + ':' + country.name + ', ' }}</span></td>

see plunker

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.