Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AngularJS嵌套ng repeat的复杂JSON数据_Json_Angularjs - Fatal编程技术网

AngularJS嵌套ng repeat的复杂JSON数据

AngularJS嵌套ng repeat的复杂JSON数据,json,angularjs,Json,Angularjs,我尝试将嵌套JSON数据访问到嵌套JSON数据中。我使用ng repeat,它适用于嵌套的JSON数据,但不适用于嵌套的JSON数据 我要捕获的数据是服务器URL及其名称 <tr ng-repeat="site in dT.data.sites"> <td>{{ site.siteName }}</td> <td><span ng-repeat="country in site.countries">{{ country.cou

我尝试将嵌套JSON数据访问到嵌套JSON数据中。我使用ng repeat,它适用于嵌套的JSON数据,但不适用于嵌套的JSON数据

我要捕获的数据是服务器URL及其名称

<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>

{{site.siteName}
{{country.country+''}}

{{country.masters.name} {{country.masters[0].name} {{master.name}}

也许我必须使用一个带有if…else方法的函数。
或者使用服务,但我更喜欢使用ng repeat。

您必须在另一个
ng repeat
中执行
ng repeat
。大概是这样的:

<td><span ng-repeat="country in site.countries"><span ng-repeat="master in country.masters">{{ master.name }}<br /></span></span></td>
{{master.name}}
我已对您的plunker进行了更改,以显示其工作:
这就是你要找的吗

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